crt: dll: Propagate failure from DLL entry point via return value instead of hard process error DLL entry point can propagate failure via FALSE return value. Use this approach instead of calling the fatal _amsg_exit() function. Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c index d72947d..65dca8d 100644 --- a/mingw-w64-crt/crt/crtdll.c +++ b/mingw-w64-crt/crt/crtdll.c
@@ -68,7 +68,8 @@ } if (__native_startup_state != __uninitialized) { - _amsg_exit (31); + ret = 1; + goto i__leave; } else { @@ -121,6 +122,7 @@ void *lock_free = NULL; void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; BOOL nested = FALSE; + BOOL failed = FALSE; while ((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock, fiberid, NULL)) != 0) { @@ -133,7 +135,7 @@ } if (__native_startup_state != __initialized) { - _amsg_exit (31); + failed = TRUE; } else { @@ -150,6 +152,10 @@ { (void) InterlockedExchangePointer (&__native_startup_lock, NULL); } + if (failed) + { + return FALSE; + } } else if (dwReason == DLL_THREAD_DETACH) {