Skip to content

Commit

Permalink
Merge pull request #168 from struct/thread_destruct_cleanup
Browse files Browse the repository at this point in the history
cleanup destruction of mutexes
  • Loading branch information
struct authored Dec 16, 2022
2 parents d9cbdfa + 9239a57 commit 2670d5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ AUTO_CTOR_DTOR = -DAUTO_CTOR_DTOR=1
## Unmap user and bitmap in the destructor. You probably
## don't want this as theres no guarantee the IsoAlloc
## destructor will be called last and other destructors
## that call free will segfault
## may reference objects within these pages
ISO_DTOR_CLEANUP = -DISO_DTOR_CLEANUP=0

## Register a signal handler for SIGSEGV that inspects si_addr
Expand Down
11 changes: 11 additions & 0 deletions src/iso_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,20 @@ INTERNAL_HIDDEN void _iso_alloc_destroy(void) {
unmap_guarded_pages(_root->chunk_lookup_table, CHUNK_TO_ZONE_TABLE_SZ);
unmap_guarded_pages(_root->chunk_quarantine, ROUND_UP_PAGE(CHUNK_QUARANTINE_SZ * sizeof(uintptr_t)));
unmap_guarded_pages(zone_cache, ROUND_UP_PAGE(ZONE_CACHE_SZ * sizeof(_tzc)));

#if THREAD_SUPPORT && !USE_SPINLOCK
UNLOCK_BIG_ZONE();
pthread_mutex_destroy(&_root->big_zone_busy_mutex);
#endif

unmap_guarded_pages(_root, sizeof(iso_alloc_root));
#endif
UNLOCK_ROOT();

#if ISO_DTOR_CLEANUP && THREAD_SUPPORT && !USE_SPINLOCK
pthread_mutex_destroy(&sane_cache_mutex);
pthread_mutex_destroy(&root_busy_mutex);
#endif
}

#if UNIT_TESTING
Expand Down

0 comments on commit 2670d5f

Please sign in to comment.