[PATCH] D11733: Runtime check of poisoning derived class members.
Evgeniy Stepanov
eugenis at google.com
Mon Aug 3 13:39:48 PDT 2015
eugenis added inline comments.
================
Comment at: test/msan/dtor-derived-class.cc:11
@@ +10,3 @@
+#include <stdio.h>
+#include<sanitizer/msan_interface.h>
+
----------------
missing space
================
Comment at: test/msan/dtor-derived-class.cc:30
@@ +29,3 @@
+int main() {
+ Derived d;
+ d.~Derived();
----------------
Allocate this with new(), otherwise you get undefined behavior at exit.
================
Comment at: test/msan/dtor-derived-class.cc:33
@@ +32,3 @@
+
+ if (__msan_test_shadow(&d, sizeof(d)) != -1)
+ printf("d is poisoned\n");
----------------
This can be re-phrased as assert(__msan_test_shadow(...) != -1).
No printfs, no checks. Don't even need FIleCheck.
================
Comment at: test/msan/dtor-derived-class.cc:34
@@ +33,3 @@
+ if (__msan_test_shadow(&d, sizeof(d)) != -1)
+ printf("d is poisoned\n");
+ else
----------------
An object may contain padding that does not have to be initialized. It's better to check user-visible things, like B::x_ and D::y_;
================
Comment at: test/msan/dtor-derived-class.cc:48
@@ +47,3 @@
+
+ if (__msan_test_shadow(&b, sizeof(b)) != -1)
+ printf("*b is poisoned\n");
----------------
Do you check that the local pointer to b is not poisoned? It's true, of course, why would it be?
http://reviews.llvm.org/D11733
More information about the cfe-commits
mailing list