diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c index aa052c7a66198..dc6add99cf602 100644 --- a/Zend/zend_fibers.c +++ b/Zend/zend_fibers.c @@ -55,7 +55,7 @@ # endif #endif -#ifdef __SANITIZE_ADDRESS__ +#if defined(__SANITIZE_ADDRESS__) && !defined(_MSC_VER) # include #endif diff --git a/ext/exif/exif.c b/ext/exif/exif.c index 74dba4bf6985f..017211bf62cf6 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -48,7 +48,7 @@ /* needed for ssize_t definition */ #include -#ifdef __SANITIZE_ADDRESS__ +#if defined(__SANITIZE_ADDRESS__) && !defined(_MSC_VER) # include #endif diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index a301888815b25..19bc6d210dd1d 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3093,7 +3093,7 @@ static int accel_startup(zend_extension *extension) #endif #ifdef ZEND_WIN32 -# if !defined(__has_feature) || !__has_feature(address_sanitizer) +# ifndef __SANITIZE_ADDRESS__ _setmaxstdio(2048); /* The default configuration is limited to 512 stdio files */ # endif #endif diff --git a/run-tests.php b/run-tests.php index 787e964571f73..bb888d8d9e41f 100755 --- a/run-tests.php +++ b/run-tests.php @@ -159,7 +159,7 @@ function main(): void $temp_source, $temp_target, $test_cnt, $test_dirs, $test_files, $test_idx, $test_list, $test_results, $testfile, $user_tests, $valgrind, $sum_results, $shuffle, $file_cache, $num_repeats, - $bless; + $bless, $asan; // Parallel testing global $workers, $workerID; global $context_line_count; @@ -363,6 +363,7 @@ function main(): void $workers = null; $context_line_count = 3; $num_repeats = 1; + $asan = false; $cfgtypes = ['show', 'keep']; $cfgfiles = ['skip', 'php', 'clean', 'out', 'diff', 'exp', 'mem']; @@ -567,6 +568,7 @@ function main(): void break; case '--asan': case '--msan': + $asan = true; $environment['USE_ZEND_ALLOC'] = 0; $environment['USE_TRACKED_ALLOC'] = 1; $environment['SKIP_ASAN'] = 1; @@ -1312,7 +1314,10 @@ function system_with_timeout( $data .= "\nTermsig=" . ($stat["exitcode"] - 128) . "\n"; } else if (defined('PHP_WINDOWS_VERSION_MAJOR') && (($stat["exitcode"] >> 28) & 0b1111) === 0b1100) { // https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781 - $data .= "\nTermsig=" . $stat["exitcode"] . "\n"; + // ignore STATUS_BAD_STACK exit codes under ASan for now + if (!$asan || $stat["exitcode"] !== -1073741784) { + $data .= "\nTermsig=" . $stat["exitcode"] . "\n"; + } } proc_close($proc); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 01c76b0e1e886..4bef1d3728f95 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1241,6 +1241,8 @@ function SAPI(sapiname, file_list, makefiletarget, cflags, obj_dir) if (PHP_SANITIZER == "yes") { if (CLANG_TOOLSET) { add_asan_opts("CFLAGS_" + SAPI, "LIBS_" + SAPI, (is_lib ? "ARFLAGS_" : "LDFLAGS_") + SAPI); + } else if (VS_TOOLSET) { + ADD_FLAG("CFLAGS", "/fsanitize=address"); } }