swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.2k stars 264 forks source link

Misaligned memory reads in lmdb #1458

Open ahoppen opened 3 weeks ago

ahoppen commented 3 weeks ago

To reproduce run

UBSAN_OPTIONS=halt_on_error=true ~/swift-latest/usr/bin/swift test --sanitize=undefined --filter testBackgroundIndexingHappensWithLowPriority

Output

Test Case '-[SourceKitLSPTests.BackgroundIndexingTests testBackgroundIndexingHappensWithLowPriority]' started.
/Users/alex/src/sourcekit-lsp/.command-line-build/checkouts/indexstore-db/lib/Database/lmdb/mdb.c:5916:14: runtime error: load of misaligned address 0x000109ddfffd for type 'unsigned short', which requires 2 byte alignment
0x000109ddfffd: note: pointer points here
 f6 57 eb d1 cf fb 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 /Users/alex/src/sourcekit-lsp/.command-line-build/checkouts/indexstore-db/lib/Database/lmdb/mdb.c:5916:14 in 
ahoppen commented 3 weeks ago

Synced to Apple’s issue tracker as rdar://129444473