This is an archive of the discontinued LLVM Phabricator instance.

Fix -fsanitize=vptr badness in <__debug>
ClosedPublic

Authored by EricWF on Feb 9 2019, 9:13 PM.

Details

Summary

This patch fixes a lifetime bug when inserting a new container into the debug database. It is
diagnosed by UBSAN when debug mode is enabled. This patch corrects how nodes are constructed
during insertion.

The fix requires unconditionally breaking the debug mode ABI. Users should not expect ABI
stability from debug mode.

Diff Detail

Repository
rCXX libc++

Event Timeline

EricWF created this revision.Feb 9 2019, 9:13 PM
mclow.lists added inline comments.
include/__debug
253

When did using replace typedef? Pretty sure it was post C++11

src/debug.cpp
241

This also appears to fix a bug where a memory allocation failure would corrupt the debug database.

EricWF marked 4 inline comments as done.Feb 10 2019, 11:39 AM
EricWF added inline comments.
include/__debug
253

using is C++11. But this header still pretends to have C++03 support so I'll write it as a typedef.

src/debug.cpp
241

Cool!

EricWF updated this revision to Diff 186160.Feb 10 2019, 11:40 AM
EricWF marked 2 inline comments as done.

Address review comments.

The fix requires unconditionally breaking the debug mode ABI. Users should not expect ABI stability from debug mode.

FWIW, this is not an issue for us.

src/debug.cpp
241–242

Are those still required?

utils/libcxx/test/config.py
942

Nice!

EricWF updated this revision to Diff 189255.Mar 4 2019, 6:08 PM
EricWF marked 2 inline comments as done.
  • Address review comments.
EricWF accepted this revision.Mar 4 2019, 6:08 PM
EricWF added inline comments.
src/debug.cpp
241–242

No. Good catch.

This revision is now accepted and ready to land.Mar 4 2019, 6:08 PM
This revision was automatically updated to reflect the committed changes.