rts: Ensure that the_gc_thread is aligned
authorBen Gamari <ben@smart-cactus.org>
Mon, 6 Aug 2018 18:52:59 +0000 (14:52 -0400)
committerBen Gamari <ben@smart-cactus.org>
Mon, 6 Aug 2018 21:53:14 +0000 (17:53 -0400)
Since we cast this to a gc_thread the compiler may assume that it's aligned.
Make sure that this is so. Fixes #15482.

rts/sm/GC.c

index 742ae36..9b31516 100644 (file)
@@ -128,7 +128,11 @@ uint32_t mutlist_MUTVARS,
 gc_thread **gc_threads = NULL;
 
 #if !defined(THREADED_RTS)
-StgWord8 the_gc_thread[sizeof(gc_thread) + 64 * sizeof(gen_workspace)];
+/* Use conservative alignment since we will cast this to a gc_thread and
+ * consequently the compiler may assume it is aligned. See #15482.
+ */
+StgWord8 the_gc_thread[sizeof(gc_thread) + 64 * sizeof(gen_workspace)]
+    __attribute__((aligned(sizeof(W_))));
 #endif
 
 // Number of threads running in *this* GC.  Affects how many