Details
Diff Detail
Event Timeline
I would say this is a follow-up for https://reviews.llvm.org/D33712, but let me see if I can build another testcase...
Lgtm with some more testing. You could modify PR33221.cpp. Something like this?
char *c = new char[16 + sizeof(Derived)]; memset((void *)c, 0, 16 + sizeof(Derived)); Derived *list = (Derived *)(c + 16); int foo = list->i;
It revealed to be a bit more complicated, so there are two tests now.
- I fixed PR33221.cpp in a way that it fails with old revisions (i.e. before https://reviews.llvm.org/D33712), but works for any other revision since then. Otherwise, the test didn't make sense, as UBSan has been reporting an error even with older revisions due to the check of Vptr against NULL value.
- I added another test for this particular CL. The idea of the test is to reproduce a case when VptrPrefix is pointing to a non accessible memory, while Vptr points to an accessible one. I haven't found a better way rather then allocate two sequential memory pages, so this extra test is Linux only.
Address comments
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
30 | With MAP_FIXED it should fail if the specified address cannot be used, so bail out in case of a failure seems to be enough. Thanks for the review! |
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
3 | One last thing. FileCheck will fail if either of the mmap's do. Could you pipe "%t &> %t.log", then in a separate RUN line, run FileCheck if the log is non-empty? Something like "cat %t.log | not count 0 && FileCheck ...". |
Now the test also works if any of the mmap calls failed.
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
3 | Oh, right! Huge thanks for the hint on how to handle that! |
LGTM, thanks for fixing this. Aside: FileCheck's has an "-input-file" option which can be useful in situations like this.
Good to know, it's useful indeed! May I ask you please to land this change as I'm not a committer yet? I'd greatly appreciate if you have a couple of minutes to do that :)
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
30 | MAP_FIXED [...] I've been unlucky enough for this to overlap AsanThread for the main thread, and has been staring at null pointers for a while. |
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
30 | Fixed in r315247. |
test/ubsan/TestCases/TypeCheck/Linux/PR33221.cpp | ||
---|---|---|
30 | Wow! Thanks for the info and for the fix! |
One last thing. FileCheck will fail if either of the mmap's do. Could you pipe "%t &> %t.log", then in a separate RUN line, run FileCheck if the log is non-empty? Something like "cat %t.log | not count 0 && FileCheck ...".