]> granicus.if.org Git - gc/commitdiff
Add assertion ensuring proper alignment of 'pushed' GC symbols
authorIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2012 17:28:07 +0000 (21:28 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 16 Feb 2012 17:28:07 +0000 (21:28 +0400)
* finalize.c (GC_push_finalizer_structures): Assert word alignment of
dl_head, fo_head, GC_finalize_now.
* pthread_support.c (GC_thr_init): Assert word alignment of GC_threads
(passed to GC_push_all).
* win32_threads.c (GC_thr_init): Likewise.
* thread_local_alloc.c (GC_init_thread_local): Assert word alignment
of GC_thread_key.
* typd_mlc.c (GC_add_ext_descriptor): Assert word alignment of
GC_ext_descriptors.

finalize.c
pthread_support.c
thread_local_alloc.c
typd_mlc.c
win32_threads.c

index 012c33579f67d24b8cf6846f014ce16bcf9f2b64..ae87e5259568992e8fe54e161845cbba8441d7d0 100644 (file)
@@ -73,6 +73,10 @@ static signed_word log_fo_table_size = -1;
 
 GC_INNER void GC_push_finalizer_structures(void)
 {
+    GC_ASSERT((word)&dl_head % sizeof(word) == 0);
+    GC_ASSERT((word)&fo_head % sizeof(word) == 0);
+    GC_ASSERT((word)&GC_finalize_now % sizeof(word) == 0);
+
     GC_push_all((ptr_t)(&dl_head), (ptr_t)(&dl_head) + sizeof(word));
     GC_push_all((ptr_t)(&fo_head), (ptr_t)(&fo_head) + sizeof(word));
     GC_push_all((ptr_t)(&GC_finalize_now),
index a376bac273cb82f83629ea87b2641b547c4d1ff1..75b6e76cb492fbf178246efbe1c823a55557fd5b 100644 (file)
@@ -976,6 +976,7 @@ GC_INNER void GC_thr_init(void)
   if (GC_thr_initialized) return;
   GC_thr_initialized = TRUE;
 
+  GC_ASSERT((word)&GC_threads % sizeof(word) == 0);
 # ifdef HANDLE_FORK
     /* Prepare for a possible fork.     */
     pthread_atfork(GC_fork_prepare_proc, GC_fork_parent_proc,
index 72d09c835c29f2525dda9c75fbac8cf0b4fda6d8..d7031e3b4bceb4f97ea9d73432e7eba171b312ac 100644 (file)
@@ -90,6 +90,7 @@ 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);
         if (0 != GC_key_create(&GC_thread_key, 0)) {
             ABORT("Failed to create key for local allocator");
         }
index 0326532a07be43aa391bf6f889c07421b0727e24..36d1e6120ab6ba93761ee8204cdc0ac69428019a 100644 (file)
@@ -126,6 +126,7 @@ STATIC signed_word GC_add_ext_descriptor(const GC_word * bm, word nbits)
         word ed_size = GC_ed_size;
 
         if (ed_size == 0) {
+            GC_ASSERT((word)&GC_ext_descriptors % sizeof(word) == 0);
             GC_push_typed_structures = GC_push_typed_structures_proc;
             UNLOCK();
             new_size = ED_INITIAL_SIZE;
index 09e8a56ac961d582a617ab86561d33f48c036a23..153463aa771a3c4135c29308861d6a816268d758 100644 (file)
@@ -2251,6 +2251,8 @@ GC_INNER void GC_thr_init(void)
 
   GC_ASSERT(I_HOLD_LOCK());
   if (GC_thr_initialized) return;
+
+  GC_ASSERT((word)&GC_threads % sizeof(word) == 0);
   GC_main_thread = GetCurrentThreadId();
   GC_thr_initialized = TRUE;