Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 691958 - =dev-libs/boost-1.65.0 has a bug which causes unaligned loads/stores on x86
Summary: =dev-libs/boost-1.65.0 has a bug which causes unaligned loads/stores on x86
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: David Seifert
URL:
Whiteboard:
Keywords:
Depends on: boost-1.71-stable
Blocks:
  Show dependency tree
 
Reported: 2019-08-11 19:50 UTC by tt_1
Modified: 2019-11-01 11:20 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2019-08-11 19:50:57 UTC
This showed when trying to validate code via UBsan (-fsanitize=undefined) with llvm/clang sanitizers in a cmake project: 

Running 2 test cases...
Connection to 127.0.0.1:1.337
Successfully connected to localhost:1.337
Connection to 127.0.0.1:1.337
Successfully connected to localhost:1.337
Connection to 127.0.0.1:1.337
Successfully connected to localhost:1.337
/usr/include/boost/endian/buffers.hpp:313:9: runtime error: store to misaligned address 0x7ffe7cfeade2 for type 'int', which requires 4 byte alignment
0x7ffe7cfeade2: note: pointer points here
 00 00  01 40 fe 7c fe 7f 00 00  20 ae fe 7c fe 7f 00 00  10 ae fe 7c fe 7f 00 00  19 e3 5e 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/boost/endian/buffers.hpp:313:9 in
Comment 1 tt_1 2019-08-11 19:52:32 UTC
upstream patch can be found here: https://github.com/boostorg/endian/pull/22

is there a chance it can be added to the stable boost-1.65.0? I tested it locally and it's a valid fix for the bug.
Comment 2 tt_1 2019-08-11 19:53:21 UTC
In any case, I'm making it depend on boost-1.70.0 stabilization
Comment 3 tt_1 2019-08-11 20:00:34 UTC
the proposed user patch was declined, instead these two fixes are the official patches, so it seems. 

https://github.com/boostorg/endian/commit/e93f6a22703249f0ebfff25302147c64965d5907

https://github.com/boostorg/endian/commit/62802fee96f002134719d02158c6fe859847fd9b
Comment 4 David Seifert gentoo-dev 2019-08-12 09:42:21 UTC
Wow, I'm surprised the author of boost endian didn't know that unaligned access (even on platforms that support it), is still undefined behavior.

While the patches are sound, I'd prefer to see this as an incentive to move to a stable boost 1.70.
Comment 5 tt_1 2019-08-12 17:40:30 UTC
I tried to backport it just for fun, but test case is too idiomatic for me, can't get my head around it. So yeah, it's best to go ahead for boost-1.70.0!
Comment 6 tt_1 2019-11-01 11:20:19 UTC
fixed by stable boost-1.71.0