Undefined behavior while running alice29.txt test with clang-5 sanitizers #180

Closed
opened 2026-01-29 20:39:22 +00:00 by claunia · 1 comment
Owner

Originally created by @geeknik on GitHub (Jun 29, 2017).

I believe this load of misaligned address to be undefined behavior. To replicate, compile brotli with bleading edge clang and throw in some sanitizers for good measure:

export CFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow"
export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow"
export LDFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow"
export CC=/third_party/llvm-build/Release+Asserts/bin/clang
export CXX=/third_party/llvm-build/Release+Asserts/bin/clang++

Run make and wait for it to happen:

Testing decompression of file tests/testdata/alice29.txt.compressed
bin/tmp/alice29.txt.uncompressed
c/dec/./bit_reader.h:114:12: runtime error: load of misaligned address 0x7f6336c74807 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
0x7f6336c74807: note: pointer points here
 12 45 a0 3b 1c  ab 40 0f 7d 2e 8a 1a d2  8a 45 5c 11 49 4b 6f af  80 af 12 78 d3 34 5d 4d  16 4f 6c
             ^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior c/dec/./bit_reader.h:114:12 in
Makefile:34: recipe for target 'test' failed
make: *** [test] Error 1
Originally created by @geeknik on GitHub (Jun 29, 2017). I believe this `load of misaligned address` to be undefined behavior. To replicate, compile brotli with bleading edge clang and throw in some sanitizers for good measure: ``` export CFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow" export CXXFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow" export LDFLAGS="-O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow" export CC=/third_party/llvm-build/Release+Asserts/bin/clang export CXX=/third_party/llvm-build/Release+Asserts/bin/clang++ ``` Run make and wait for it to happen: ``` Testing decompression of file tests/testdata/alice29.txt.compressed bin/tmp/alice29.txt.uncompressed c/dec/./bit_reader.h:114:12: runtime error: load of misaligned address 0x7f6336c74807 for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment 0x7f6336c74807: note: pointer points here 12 45 a0 3b 1c ab 40 0f 7d 2e 8a 1a d2 8a 45 5c 11 49 4b 6f af 80 af 12 78 d3 34 5d 4d 16 4f 6c ^ SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior c/dec/./bit_reader.h:114:12 in Makefile:34: recipe for target 'test' failed make: *** [test] Error 1 ```
Author
Owner

@geeknik commented on GitHub (Jun 29, 2017):

After reading some prior reports, I'll close this.

@geeknik commented on GitHub (Jun 29, 2017): After reading some prior reports, I'll close this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#180