Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL), 10.10(EOL), 10.11, 11.0(EOL), 11.1(EOL)
Description
Recently, MSAN_OPTIONS=poison_in_dtor=1 was enabled by default. This caught some foul play in InnoDB (to be fixed in MDEV-30936) as well as massive amounts of failures in free_root(), because the root->used or root->free lists could be marked as uninitialized in various destructors for objects that are allocated from a MEM_ROOT.
It would be good programming style to make sure that MemorySanitizer does not report any errors when MSAN_OPTIONS=poison_in_dtor=1 is set.
It is possible to work around the errors with the following patch:
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
|
index aa0182c755e..b9071ad7eee 100644
|
--- a/mysys/my_alloc.c
|
+++ b/mysys/my_alloc.c
|
@@ -415,14 +415,26 @@ void free_root(MEM_ROOT *root, myf MyFlags)
|
if (!(MyFlags & MY_KEEP_PREALLOC))
|
root->pre_alloc=0;
|
|
+#if __has_feature(memory_sanitizer)
|
+ /* Work around MSAN_OPTIONS=poison_in_dtor=1 */
|
+ MEM_MAKE_DEFINED(&root->used, sizeof root->used);
|
+ MEM_MAKE_DEFINED(&root->free, sizeof root->free);
|
+#endif
|
+
|
for (next=root->used; next ;)
|
{
|
+#if __has_feature(memory_sanitizer)
|
+ MEM_MAKE_DEFINED(&next->next, sizeof next->next);
|
+#endif
|
old=next; next= next->next ;
|
if (old != root->pre_alloc)
|
my_free(old);
|
}
|
for (next=root->free ; next ;)
|
{
|
+#if __has_feature(memory_sanitizer)
|
+ MEM_MAKE_DEFINED(&next->next, sizeof next->next);
|
+#endif
|
old=next; next= next->next;
|
if (old != root->pre_alloc)
|
my_free(old); |
I think that explicitly setting MSAN_OPTIONS=poison_in_dtor=0 when using Clang 15 or later is a lesser evil. The above patch could mask other errors as well.
Attachments
Issue Links
- relates to
-
MDEV-35516 MSAN_OPTIONS=poison_in_dtor=1 sp_lex_keeper
- Open
-
MDEV-20377 Make WITH_MSAN more usable
- Closed
-
MDEV-30936 clang 15.0.7 -fsanitize=memory fails massively
- Closed