Skip to content

Commit ec9cdcd

Browse files
authored
Fix MSan false-positive in zend_max_execution_timer (#15408)
Explicitly mark memory regions as unpoisoned for zend_max_execution_timer on ZTS, as MemorySanitizer in clang >= 18 causes false positives.
1 parent 8c3f5f9 commit ec9cdcd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Zend/zend_max_execution_timer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include <sys/syscall.h>
2525
#include <sys/types.h>
2626

27+
#if __has_feature(memory_sanitizer)
28+
# include <sanitizer/msan_interface.h>
29+
#endif
30+
2731
#include "zend.h"
2832
#include "zend_globals.h"
2933

@@ -47,6 +51,12 @@ ZEND_API void zend_max_execution_timer_init(void) /* {{{ */
4751
sev.sigev_signo = SIGRTMIN;
4852
sev.sigev_notify_thread_id = (pid_t) syscall(SYS_gettid);
4953

54+
#if __has_feature(memory_sanitizer)
55+
/* MSan does not intercept timer_create() */
56+
__msan_unpoison(&EG(max_execution_timer_timer),
57+
sizeof(EG(max_execution_timer_timer)));
58+
#endif
59+
5060
// Measure wall time instead of CPU time as originally planned now that it is possible https://github.com/php/php-src/pull/6504#issuecomment-1370303727
5161
if (timer_create(CLOCK_BOOTTIME, &sev, &EG(max_execution_timer_timer)) != 0) {
5262
zend_strerror_noreturn(E_ERROR, errno, "Could not create timer");

0 commit comments

Comments
 (0)