Skip to content

Commit ebdf9ba

Browse files
committed
test(mem): unpoison mimalloc output before the handler reads it
The MSan output handler checked msg[0] before marking the text initialized, so MSan reported the handler's own read (tests/test_main.c:2151). Unpoison first, then test for the empty replay. Signed-off-by: Martin Vogel <[email protected]>
1 parent 0f8b465 commit ebdf9ba

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tests/test_main.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,10 +2148,14 @@ static void tf_msan_mi_output(const char *msg, void *arg) {
21482148
/* Registering replays mimalloc's delayed-output buffer into the handler.
21492149
* Its constructor already wrote all of that to stderr before main, so the
21502150
* replay would only repeat it behind a stray newline: skip it. */
2151-
if (!tf_msan_mi_output_live || !msg || !msg[0]) {
2151+
if (!tf_msan_mi_output_live || !msg) {
21522152
return;
21532153
}
2154+
/* Mark the text initialized before reading even its first byte. */
21542155
__msan_unpoison_string(msg);
2156+
if (!msg[0]) {
2157+
return;
2158+
}
21552159
(void)fputs(msg, stderr);
21562160
}
21572161
#endif

0 commit comments

Comments
 (0)