diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-03-17 09:56:10 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-03-17 15:01:21 +0300 |
commit | ad112a13bdfb04ae7ff768668ba6616577cc100d (patch) | |
tree | 2d84d8e12c239a2f8a6542865c76c330b42bd7b7 /thread_local_alloc.c | |
parent | 6c63aba2e25ed05005e49a12e187e03063732dd1 (diff) | |
download | bdwgc-ad112a13bdfb04ae7ff768668ba6616577cc100d.tar.gz |
Fix assertion violation of GC_thread_key alignment if pthread-based TLS
(fix of commit d692eb432)
It is needed to push GC_thread_key only in case of USE_CUSTOM_SPECIFIC;
it could have any alignment otherwise (e.g., if it is of pthread_key_t
type).
* thread_support.c [THREAD_LOCAL_ALLOC] (GC_push_thread_structures):
Push GC_thread_key only if USE_CUSTOM_SPECIFIC.
* win32_threads.c [THREAD_LOCAL_ALLOC] (GC_push_thread_structures):
Likewise.
* thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_init_thread_local): Do
not assert GC_thread_key is word-aligned unless USE_CUSTOM_SPECIFIC;
add comment.
Diffstat (limited to 'thread_local_alloc.c')
-rw-r--r-- | thread_local_alloc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/thread_local_alloc.c b/thread_local_alloc.c index 52c5863f..900bcaeb 100644 --- a/thread_local_alloc.c +++ b/thread_local_alloc.c @@ -98,7 +98,10 @@ GC_INNER void GC_init_thread_local(GC_tlfs p) GC_ASSERT(I_HOLD_LOCK()); if (!EXPECT(keys_initialized, TRUE)) { - GC_ASSERT((word)&GC_thread_key % sizeof(word) == 0); +# ifdef USE_CUSTOM_SPECIFIC + /* Ensure proper alignment of a "pushed" GC symbol. */ + GC_ASSERT((word)&GC_thread_key % sizeof(word) == 0); +# endif res = GC_key_create(&GC_thread_key, reset_thread_key); if (COVERT_DATAFLOW(res) != 0) { ABORT("Failed to create key for local allocator"); |