Skip to content

[NativeAOT] possible deadlock due to InitializeRuntime reentrancy if ModuleInitializer launches threads. #107699

@VSadov

Description

@VSadov

While playing with alternatives for stress testing, I tried spawning a thread from a module initializer, that would do GC.Collect in a loop and other stress(y) things.

Some tests seem to hang with that:

  • InitializeRuntime calls module initializers, which is arbitrary app code and may launch a thread.
  • launching a thread waits for the thread to start running.
  • to start running, a thread needs to do a reverse PInvoke, which spin-waits for InitializeRuntime to complete.

Perhaps we should finish runtime initialization before calling into module initializers?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions