This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][NFC] Fix UB due to unaligned load in DebugStrOffsetsWriter
ClosedPublic

Authored by jobnoorman on Apr 13 2023, 5:14 AM.

Details

Summary

The following tests fail when enabling UBSan due to an unaligned memory
load:

runtime error: load of misaligned address 0x620000000643 for type
'const uint32_t' (aka 'const unsigned int'), which requires 4 byte
alignment

BOLT :: AArch64/asm-func-debug.test
BOLT :: AArch64/update-debug-reloc.test
BOLT :: X86/asm-func-debug.test
BOLT :: X86/dwarf5-df-dualcu.test
BOLT :: X86/dwarf5-df-mono-dualcu.test
BOLT :: X86/dwarf5-ftypes-dwp-input-dwo-output.test
BOLT :: X86/dwarf5-locaddrx.test
BOLT :: X86/dwarf5-split-dwarf4-monolithic.test
BOLT :: X86/inlined-function-mixed.test
BOLT :: non-empty-debug-line.test

This patch fixes this by using read32le for the load.

Diff Detail

Event Timeline

jobnoorman created this revision.Apr 13 2023, 5:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 5:14 AM
jobnoorman requested review of this revision.Apr 13 2023, 5:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2023, 5:14 AM
ayermolo accepted this revision.Apr 13 2023, 7:26 AM
This revision is now accepted and ready to land.Apr 13 2023, 7:26 AM

Thanks for catching it.