[SERVER-22713] AlignedBuilder exhibits UB via misaligned loads/stores Created: 17/Feb/16  Updated: 13/Jan/17  Resolved: 13/Jan/17

Status: Closed
Project: Core Server
Component/s: MMAPv1
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Won't Fix Votes: 0
Labels: undefined-sanitizer
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Run any jscore test with MMAPv1 as the storage engine.

Participants:

 Description   

See https://github.com/mongodb/mongo/blob/742f15bfcf2173103498a81f56503c9746b4e93d/src/mongo/db/storage/mmap_v1/aligned_builder.h#L83-L99

The undefined behavior sanitizer complains:

[MongoDFixture:job0] src/mongo/db/storage/mmap_v1/aligned_builder.h:99:9: runtime error: store to misaligned address 0x7fb230306004 for type 'unsigned long long', which requires 8 byte alignment
[MongoDFixture:job0] 0x7fb230306004: note: pointer points here
[MongoDFixture:job0]   fd ff ff ff 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
[MongoDFixture:job0]               ^
[MongoDFixture:job0]     #0 0x1a380bb in mongo::AlignedBuilder::appendNum(unsigned long long) /home/andrew/Documents/10gen/dev/src/mongodb/src/mongo/db/storage/mmap_v1/aligned_builder.h:99:9
[MongoDFixture:job0]     #1 0x1a380bb in mongo::dur::FileCreatedOp::_serialize(mongo::AlignedBuilder&) /home/andrew/Documents/10gen/dev/src/mongodb/src/mongo/db/storage/mmap_v1/durop.cpp:121
[MongoDFixture:job0]     #2 0x1a21bc2 in mongo::dur::_PREPLOGBUFFER(mongo::dur::JSectHeader&, mongo::AlignedBuilder&) /home/andrew/Documents/10gen/dev/src/mongodb/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp:185:10
[MongoDFixture:job0]     #3 0x1a21bc2 in mongo::dur::PREPLOGBUFFER(mongo::dur::JSectHeader&, mongo::AlignedBuilder&) /home/andrew/Documents/10gen/dev/src/mongodb/src/mongo/db/storage/mmap_v1/dur_preplogbuffer.cpp:198
[MongoDFixture:job0]     #4 0x1a0deeb in mongo::dur::durThread() /home/andrew/Documents/10gen/dev/src/mongodb/src/mongo/db/storage/mmap_v1/dur.cpp:744:17
[MongoDFixture:job0]     #5 0x7fb23238c02f  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb902f)
[MongoDFixture:job0]     #6 0x7fb2320bc6a9 in start_thread /build/buildd/glibc-2.21/nptl/pthread_create.c:333

Note that these are also not endian clean


Generated at Thu Feb 08 04:01:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.