Skip to content
  • Cheng Shao's avatar
    dfaea455
    rts: ensure gc_thread/gen_workspace is allocated with proper alignment · dfaea455
    Cheng Shao authored
    gc_thread/gen_workspace are required to be aligned by 64 bytes.
    However, this property has not been properly enforced before, and
    numerous alignment violations at runtime has been caught by
    UndefinedBehaviorSanitizer that look like:
    
    ```
    rts/sm/GC.c:1167:8: runtime error: member access within misaligned address 0x0000027a3390 for type 'gc_thread' (aka 'struct gc_thread_'), which requires 64 byte alignment
    0x0000027a3390: note: pointer points here
     00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                  ^
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1167:8
    
    rts/sm/GC.c:1184:13: runtime error: member access within misaligned address 0x0000027a3450 for type 'gen_workspace' (aka 'struct gen_workspace_'), which requires 64 byte alignment
    0x0000027a3450: note: pointer points here
     00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                  ^
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1184:13
    ```
    
    This patch fixes the gc_thread/gen_workspace misalignment issue by
    explicitly allocating them with alignment constraint.
    
    (cherry picked from commit 7a660042)
    dfaea455
    rts: ensure gc_thread/gen_workspace is allocated with proper alignment
    Cheng Shao authored
    gc_thread/gen_workspace are required to be aligned by 64 bytes.
    However, this property has not been properly enforced before, and
    numerous alignment violations at runtime has been caught by
    UndefinedBehaviorSanitizer that look like:
    
    ```
    rts/sm/GC.c:1167:8: runtime error: member access within misaligned address 0x0000027a3390 for type 'gc_thread' (aka 'struct gc_thread_'), which requires 64 byte alignment
    0x0000027a3390: note: pointer points here
     00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                  ^
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1167:8
    
    rts/sm/GC.c:1184:13: runtime error: member access within misaligned address 0x0000027a3450 for type 'gen_workspace' (aka 'struct gen_workspace_'), which requires 64 byte alignment
    0x0000027a3450: note: pointer points here
     00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                  ^
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1184:13
    ```
    
    This patch fixes the gc_thread/gen_workspace misalignment issue by
    explicitly allocating them with alignment constraint.
    
    (cherry picked from commit 7a660042)
Loading