Skip to content

Commit 2670d5f

Browse files
authored
Merge pull request #168 from struct/thread_destruct_cleanup
cleanup destruction of mutexes
2 parents d9cbdfa + 9239a57 commit 2670d5f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ AUTO_CTOR_DTOR = -DAUTO_CTOR_DTOR=1
181181
## Unmap user and bitmap in the destructor. You probably
182182
## don't want this as theres no guarantee the IsoAlloc
183183
## destructor will be called last and other destructors
184-
## that call free will segfault
184+
## may reference objects within these pages
185185
ISO_DTOR_CLEANUP = -DISO_DTOR_CLEANUP=0
186186

187187
## Register a signal handler for SIGSEGV that inspects si_addr

src/iso_alloc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,9 +1989,20 @@ INTERNAL_HIDDEN void _iso_alloc_destroy(void) {
19891989
unmap_guarded_pages(_root->chunk_lookup_table, CHUNK_TO_ZONE_TABLE_SZ);
19901990
unmap_guarded_pages(_root->chunk_quarantine, ROUND_UP_PAGE(CHUNK_QUARANTINE_SZ * sizeof(uintptr_t)));
19911991
unmap_guarded_pages(zone_cache, ROUND_UP_PAGE(ZONE_CACHE_SZ * sizeof(_tzc)));
1992+
1993+
#if THREAD_SUPPORT && !USE_SPINLOCK
1994+
UNLOCK_BIG_ZONE();
1995+
pthread_mutex_destroy(&_root->big_zone_busy_mutex);
1996+
#endif
1997+
19921998
unmap_guarded_pages(_root, sizeof(iso_alloc_root));
19931999
#endif
19942000
UNLOCK_ROOT();
2001+
2002+
#if ISO_DTOR_CLEANUP && THREAD_SUPPORT && !USE_SPINLOCK
2003+
pthread_mutex_destroy(&sane_cache_mutex);
2004+
pthread_mutex_destroy(&root_busy_mutex);
2005+
#endif
19952006
}
19962007

19972008
#if UNIT_TESTING

0 commit comments

Comments
 (0)