summaryrefslogtreecommitdiff
path: root/include/my_valgrind.h
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-08-13 19:28:51 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-08-13 19:28:51 +0300
commit65d48b4a7bd7a57a27f2e9ca54473e1ae86223b5 (patch)
treef145a7a095011fbc4e6661e1675f72f6cdca38b6 /include/my_valgrind.h
parenteedd6179c1e5e8651270b353a693887179ad7bf3 (diff)
parented4ccf34a6603bd2374a721a7e1ad88472f335fc (diff)
downloadmariadb-git-65d48b4a7bd7a57a27f2e9ca54473e1ae86223b5.tar.gz
Merge 10.2 to 10.3
Diffstat (limited to 'include/my_valgrind.h')
-rw-r--r--include/my_valgrind.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 9159ec5b138..08ad3f46b96 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -55,12 +55,19 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
#endif /* HAVE_VALGRIND_MEMCHECK_H */
#if defined(TRASH_FREED_MEMORY)
+/* NOTE: Do not invoke TRASH_FILL directly! Use TRASH_ALLOC or TRASH_FREE.
+
+The MEM_UNDEFINED() call before memset() is for canceling the effect
+of any previous MEM_NOACCESS(). We must invoke MEM_UNDEFINED() after
+writing the dummy pattern, unless MEM_NOACCESS() is going to be invoked.
+On AddressSanitizer, the MEM_UNDEFINED() in TRASH_ALLOC() has no effect. */
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
-#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)
+#define TRASH_FILL(A,B,C) while (0)
#endif
-
+/** Note that some memory became allocated or uninitialized. */
#define TRASH_ALLOC(A,B) do { TRASH_FILL(A,B,0xA5); MEM_UNDEFINED(A,B); } while(0)
+/** Note that some memory became freed. (Prohibit further access to it.) */
#define TRASH_FREE(A,B) do { TRASH_FILL(A,B,0x8F); MEM_NOACCESS(A,B); } while(0)
#endif /* MY_VALGRIND_INCLUDED */