Fix the static cleanup mechanism introduced to the runtime_loader/libroot:

* Fixed wrong start and size used in the runtime_loader
* Fixed off by one error in the matching loop of the cleanup hook
* Make sure we successfully acquire the locking sem of the exit stack

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23493 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-01-13 18:49:27 +00:00
parent 4fc4f2c8ae
commit 3be509a228
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -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])();
+1 -1
View File
@@ -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)