Skip to content

The app crashes under .NET7 in Docker with "Fatal error. The RW block to unmap was not found" #80580

@SergeiPavlov

Description

@SergeiPavlov

Description

When we switch to .NET7 from .NET6 we often see "Fatal error. The RW block to unmap was not found"

There are 2 places in dotnet code with this message:
https://github.com/dotnet/runtime/blob/main/src/coreclr/utilcode/executableallocator.cpp#L280
https://github.com/dotnet/runtime/blob/main/src/coreclr/utilcode/executableallocator.cpp#L845

Under .NET6 never seen such an error.
DOTNET_EnableWriteXorExecute=0 setting helps to avoid it, but then OutOfMemory does appear, even when there is enough free memory for Heap and unmanaged needs.

Reproduction Steps

.NET7 ASP NET app under Docker-in-Docker environment

Expected behavior

No crash

Actual behavior

Stack trace may be various. Example:

Fatal error. The RW block to unmap was not found
   at System.Reactive.Concurrency.DefaultScheduler.Schedule[[System.ValueTuple`2[[System.Reactive.Concurrency.LocalScheduler, System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263],[System.Reactive.Disposables.SingleAssignmentDisposable, System.Reactive, Version=5.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.ValueTuple`2<System.Reactive.Concurrency.LocalScheduler,System.Reactive.Disposables.SingleAssignmentDisposable>, System.Func`3<System.Reactive.Concurrency.IScheduler,System.ValueTuple`2<System.Reactive.Concurrency.LocalScheduler,System.Reactive.Disposables.SingleAssignmentDisposable>,System.IDisposable>)
   at System.Reactive.Concurrency.DefaultScheduler.Schedule[[System.ValueTuple`2[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.ValueTuple`2<System.__Canon,System.__Canon>, System.TimeSpan, System.Func`3<System.Reactive.Concurrency.IScheduler,System.ValueTuple`2<System.__Canon,System.__Canon>,System.IDisposable>)
   at System.Reactive.Concurrency.LocalScheduler.ScheduleShortTermWork(WorkItem)
   at System.Reactive.Concurrency.LocalScheduler.EvaluateLongTermQueue()
   at System.Reactive.Concurrency.LocalScheduler.SystemClockChanged(System.Object, System.Reactive.PlatformServices.SystemClockChangedEventArgs)
   at System.Reactive.PlatformServices.SystemClock.OnSystemClockChanged(System.Object, System.Reactive.PlatformServices.SystemClockChangedEventArgs)
   at System.Reactive.PlatformServices.PeriodicTimerSystemClockMonitor.TimeChanged()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.TimerQueueTimer.Fire(Boolean)
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
[createdump] Problem suspending threads: ptrace(ATTACH, 6) FAILED Operation not permitted (1)
[createdump] Failure took 0ms

Regression?

On .NET6 it does work.

Known Workarounds

DOTNET_EnableWriteXorExecute=0 but it induces OutOfMemory exception more often

Configuration

Based on image mcr.microsoft.com/dotnet/aspnet:7.0.2-bullseye-slim-amd64
We have limited .NET memory consumption by settings:
Docker-compose's

    mem_limit: 39g
    mem_reservation: 36g

Env var:
DOTNET_GCHeapHardLimit: "3C0000000"

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions