[PATCH] D102684: [LLD] Allow disabling the early exit codepath as a build configuration

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 12:04:49 PDT 2021


amccarth added a comment.

In D102684#2775573 <https://reviews.llvm.org/D102684#2775573>, @mstorsjo wrote:

> While exiting from a non-main thread is tricky, things also do hang when exiting from the main thread, when bypassing constructors. The fatal issue there is that we have a number of threads still running, that can keep various locks. When exiting, all other threads are stopped where they are, and we run the destructors for DLLs.

I guess I misread a few sources.  ExitProcess first terminates all threads other than the calling thread.  I expected that would force the terminated threads to release all of their synchronization objects, thus preventing many types of deadlocks.  But now I see that the synchronization objects are not released until later--when all of the process's kernel objects are reclaimed.

I assumed the short circuit option would just skip running destructors for statics in the DLLs (by having the DLLs do nothing on DLL_PROCESS_DETACH), but I see in the stack trace that it's libc++'s DllMain, which is outside our scope.  Bummer.

Of course, the real mind bender is wondering why the "universal" CRT needs to setjmp (?!) (and therefore allocate memory) during shutdown.  Yikes!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102684/new/

https://reviews.llvm.org/D102684



More information about the llvm-commits mailing list