diff --git a/src/system/libroot/posix/stdlib/exit.c b/src/system/libroot/posix/stdlib/exit.c index c1bf1832bb..ee13b0fb95 100644 --- a/src/system/libroot/posix/stdlib/exit.c +++ b/src/system/libroot/posix/stdlib/exit.c @@ -46,8 +46,10 @@ _exit_stack_lock() { thread_id self = find_thread(NULL); if (self != sExitStackInfo.lock_owner) { - if (atomic_add(&sExitStackInfo.lock_count, 1) > 0) - acquire_sem(sExitStackInfo.lock); + if (atomic_add(&sExitStackInfo.lock_count, 1) > 0) { + while (acquire_sem(sExitStackInfo.lock) != B_OK) + ; + } sExitStackInfo.lock_owner = self; } sExitStackInfo.recursion_count++; @@ -75,7 +77,7 @@ _call_atexit_hooks_for_range(addr_t start, addr_t size) int32 insertIndex = -1; _exit_stack_lock(); - for (index = sExitStackInfo.stack_size - 1; index > 0; index--) { + for (index = sExitStackInfo.stack_size - 1; index >= 0; index--) { addr_t function = (addr_t)sExitStackInfo.exit_stack[index]; if (function >= start && function < start + size) { (*sExitStackInfo.exit_stack[index])(); diff --git a/src/system/runtime_loader/elf.cpp b/src/system/runtime_loader/elf.cpp index b1535e5245..fcc17b4cfc 100644 --- a/src/system/runtime_loader/elf.cpp +++ b/src/system/runtime_loader/elf.cpp @@ -1460,7 +1460,7 @@ unload_library(image_id imageID, bool addOn) // call image fini here... if (gRuntimeLoader.call_atexit_hooks_for_range) { gRuntimeLoader.call_atexit_hooks_for_range( - image->regions[0].start, image->regions[0].size); + image->regions[0].vmstart, image->regions[0].vmsize); } if (image->term_routine)