This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.
ClosedPublic

Authored by EricWF on Dec 27 2016, 3:43 PM.

Details

Summary

This patch fixes llvm.org/PR31402 by replacing map::__find_equal_key with __tree::__find_equal, which has already addressed the same undefined behavior.

Unfortunately I haven't been able to write a test case which causes the UBSAN diagnostic mentioned in the bug report. I can write tests which exercise the UB but for some reason they do not cause UBSAN to fail. Any help writing a test case would be appreciated.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 82564.Dec 27 2016, 3:43 PM
EricWF retitled this revision from to [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior..
EricWF updated this object.
EricWF added reviewers: mclow.lists, vsk.
EricWF added a subscriber: cfe-commits.
vsk edited edge metadata.Dec 29 2016, 3:33 PM

LGTM. I'm not sure what to do for a test. Have you tried checking the IR for the affected object file in tablegen at '-O2 -fsanitize=undefined'? If there's an unconditional call to the ubsan handler, maybe the tablegen source could be used to find a small reproducer?

EricWF accepted this revision.Jan 4 2017, 10:16 PM
EricWF added a reviewer: EricWF.
In D28131#632516, @vsk wrote:

LGTM. I'm not sure what to do for a test. Have you tried checking the IR for the affected object file in tablegen at '-O2 -fsanitize=undefined'? If there's an unconditional call to the ubsan handler, maybe the tablegen source could be used to find a small reproducer?

Good idea. I'll have to try that, however I'll try to write a test post-commit.

This revision is now accepted and ready to land.Jan 4 2017, 10:16 PM
EricWF closed this revision.Jan 4 2017, 10:17 PM
mclow.lists added inline comments.Jan 5 2017, 9:26 AM
include/__tree
1400

Didn't we address this in http://wg21.link/LWG2542 ?