This is an archive of the discontinued LLVM Phabricator instance.

runtime flag for use-after dtor and v simple runtime test
ClosedPublic

Authored by nmusgrave on Jul 16 2015, 4:24 PM.

Details

Reviewers
kcc
eugenis

Diff Detail

Event Timeline

nmusgrave updated this revision to Diff 29961.Jul 16 2015, 4:24 PM
nmusgrave retitled this revision from to runtime flag for use-after dtor and v simple runtime test.
nmusgrave updated this object.
nmusgrave added reviewers: kcc, eugenis.
nmusgrave added a subscriber: cfe-commits.
eugenis added inline comments.Jul 16 2015, 4:35 PM
include/sanitizer/msan_interface.h
96

Make it "const volatile *".

lib/msan/msan_interface_internal.h
120

Don't need this.

test/msan/dtor-member.cc
2

Add -O1 and -O2 runs.

20

return is unnecessary

nmusgrave marked 3 inline comments as done.Jul 16 2015, 4:43 PM
nmusgrave added inline comments.
include/sanitizer/msan_interface.h
96
  • why? I was looking at msan_allocated_memory and saw the const volatile void* parameter, but don't understand why its const. Since the memory is being poisoned, shouldn't it -not- be const?
  • ...or can the parameter be const since its not the memory at this location, but the shadow memory, that's marked as poisoned?
  • also: naming conventions. Shouldn't it be __msan_dtor_callback? That seems to align better with the other msan runtime functions here. If so, I'll change the naming in codegen/
eugenis added inline comments.Jul 16 2015, 4:49 PM
include/sanitizer/msan_interface.h
96

This only really matters for functions the would be called from the user code. The idea is that even if some memory is "const", we can mark it as uninitialized or not.

The name starts with __sanitizer because it may be implemented in other sanitizers, too. Maybe in the future. ASan can be taught to detect use-after-dtor too, for example, but with some false positives.

nmusgrave updated this revision to Diff 29964.Jul 16 2015, 4:55 PM
  • resolved runtime function parameters
eugenis added inline comments.Jul 17 2015, 10:16 AM
test/msan/dtor-member.cc
10

Please add run lines without (a) compiler flag and (b) runtime flag.

23

If we don't crash on the next line (in the negative test), there will be a second destructor call at the function exit, which invokes undefined behavior. Let's change the code to smth like this:

unsigned long buf[1];
assert(sizeof(Simple) <= sizeof(buf));
Simple *s = new(&buf) Simple();
s->~Simple();

nmusgrave updated this revision to Diff 30026.Jul 17 2015, 1:15 PM
  • added tests for without compile and runtime flags
eugenis accepted this revision.Jul 17 2015, 1:25 PM
eugenis edited edge metadata.

LGTM

lib/msan/msan_interceptors.cc
1011

FYI, this tag affects the wording of MSan reports. We may want to introduce a new tag, specifically for use-after-dtor. Not in this commit.

test/msan/dtor-member.cc
12

Could just call it "CHECK-NO" and save one line of code.

19

I don't think this include is needed.

37

"interfere"

This revision is now accepted and ready to land.Jul 17 2015, 1:25 PM
nmusgrave updated this revision to Diff 30033.Jul 17 2015, 1:41 PM
nmusgrave marked 3 inline comments as done.
nmusgrave edited edge metadata.
  • modified run prefix
nmusgrave added inline comments.Jul 17 2015, 4:58 PM
test/msan/dtor-member.cc
20

needed for main- can't have void main function. may rename as add more test cases.

nmusgrave closed this revision.Jul 17 2015, 5:09 PM

revision alterations have been landed and changes pushed onto trunk