From 43643378d44899c44fb148454a4d8162e7b1a78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 20 Jul 2026 13:52:21 +0200 Subject: [PATCH 1/5] ext/lexbor: Enable ASAN support in Lexbor --- ext/lexbor/config.m4 | 5 +++++ ext/lexbor/config.w32 | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ext/lexbor/config.m4 b/ext/lexbor/config.m4 index 43123578a727..2621cdb02fda 100644 --- a/ext/lexbor/config.m4 +++ b/ext/lexbor/config.m4 @@ -1,4 +1,9 @@ PHP_LEXBOR_CFLAGS="-Wno-unknown-warning-option -Wno-unterminated-string-initialization -I@ext_srcdir@/" + +if test "$PHP_ADDRESS_SANITIZER" = "yes"; then + PHP_LEXBOR_CFLAGS="$PHP_LEXBOR_CFLAGS -DLEXBOR_HAVE_ADDRESS_SANITIZER=1" +fi + LEXBOR_DIR="lexbor" AC_DEFINE([HAVE_LEXBOR], [1], [Define to 1 if the PHP extension 'lexbor' is available.]) diff --git a/ext/lexbor/config.w32 b/ext/lexbor/config.w32 index 403c3b98afb5..7ac8ec9bb471 100644 --- a/ext/lexbor/config.w32 +++ b/ext/lexbor/config.w32 @@ -25,6 +25,10 @@ ADD_SOURCES("ext/lexbor/lexbor/unicode", "idna.c unicode.c","lexbor"); ADD_SOURCES("ext/lexbor/lexbor/url", "url.c","lexbor"); ADD_FLAG("CFLAGS_LEXBOR", "/D LEXBOR_BUILDING /utf-8"); +if (PHP_ADDRESS_SANITIZER == "yes") { + ADD_FLAG("CFLAGS_LEXBOR", "/D LEXBOR_HAVE_ADDRESS_SANITIZER=1"); +} + AC_DEFINE("HAVE_LEXBOR", 1, "Define to 1 if the PHP extension 'lexbor' is available."); PHP_INSTALL_HEADERS("ext/lexbor", "php_lexbor.h lexbor/"); From f389497c69babcf8ec84f048d67d1834748ee146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 21 Jul 2026 16:22:08 +0200 Subject: [PATCH 2/5] Try to fix Windows build --- ext/lexbor/config.w32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/lexbor/config.w32 b/ext/lexbor/config.w32 index 7ac8ec9bb471..2b81bc60397f 100644 --- a/ext/lexbor/config.w32 +++ b/ext/lexbor/config.w32 @@ -25,7 +25,7 @@ ADD_SOURCES("ext/lexbor/lexbor/unicode", "idna.c unicode.c","lexbor"); ADD_SOURCES("ext/lexbor/lexbor/url", "url.c","lexbor"); ADD_FLAG("CFLAGS_LEXBOR", "/D LEXBOR_BUILDING /utf-8"); -if (PHP_ADDRESS_SANITIZER == "yes") { +if (PHP_SANITIZER == "yes") { ADD_FLAG("CFLAGS_LEXBOR", "/D LEXBOR_HAVE_ADDRESS_SANITIZER=1"); } From 0e135692747e8d32c07c4a2fb1c53434482a694f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 21 Jul 2026 16:27:16 +0200 Subject: [PATCH 3/5] Test in CI --- ext/lexbor/lexbor/core/mraw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/lexbor/lexbor/core/mraw.c b/ext/lexbor/lexbor/core/mraw.c index c9904050dd84..7031a03333f9 100644 --- a/ext/lexbor/lexbor/core/mraw.c +++ b/ext/lexbor/lexbor/core/mraw.c @@ -166,6 +166,7 @@ lexbor_mraw_mem_alloc(lexbor_mraw_t *mraw, size_t length) mem->chunk_length++; #if defined(LEXBOR_HAVE_ADDRESS_SANITIZER) + printf("asd"); ASAN_POISON_MEMORY_REGION(mem->chunk->data, mem->chunk->size); #endif } From de0f4a69b73571ebc67960f694deb255ef5691d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 21 Jul 2026 23:40:25 +0200 Subject: [PATCH 4/5] Try to fix CI config to enable ASAN and UBSAN --- .github/actions/configure-x64/action.yml | 2 ++ .github/workflows/test-suite.yml | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/actions/configure-x64/action.yml b/.github/actions/configure-x64/action.yml index ff746791fb95..1cd5fe66c6ca 100644 --- a/.github/actions/configure-x64/action.yml +++ b/.github/actions/configure-x64/action.yml @@ -81,4 +81,6 @@ runs: ${{ inputs.skipSlow == 'false' && '--with-pdo-firebird' || '' }} \ ${{ inputs.skipSlow == 'false' && '--with-pdo-dblib' || '' }} \ --enable-werror \ + ${{ inputs.asan == 'true' && '--enable-address-sanitizer' || '' }} \ + ${{ inputs.asan == 'true' && '--enable-undefined-sanitizer' || '' }} \ ${{ inputs.configurationParameters }} diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index efe5a650d2c6..8afe48421ca6 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -34,11 +34,13 @@ jobs: uses: ./.github/actions/configure-gentoo with: configurationParameters: >- - CFLAGS="-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" - LDFLAGS="-fsanitize=undefined,address -fno-sanitize=function" + CFLAGS="-fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" + LDFLAGS="-fno-sanitize=function" CC=clang-17 CXX=clang++-17 --enable-debug + --enable-address-sanitizer + --enable-undefined-sanitizer --enable-zts skipSlow: false # FIXME: This should likely include slow extensions - name: make @@ -84,10 +86,12 @@ jobs: uses: ./.github/actions/configure-alpine with: configurationParameters: >- - CFLAGS="-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" - LDFLAGS="-fsanitize=undefined,address -fno-sanitize=function" + CFLAGS="-fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" + LDFLAGS="-fno-sanitize=function" --enable-debug --enable-zts + --enable-address-sanitizer + --enable-undefined-sanitizer skipSlow: true # FIXME: This should likely include slow extensions - name: make run: make -j$(/usr/bin/nproc) >/dev/null @@ -165,7 +169,7 @@ jobs: uses: ./.github/actions/configure-x64 with: configurationParameters: >- - ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address"' || '' }} + ${{ matrix.asan && 'CFLAGS="-DZEND_TRACK_ARENA_ALLOC" LDFLAGS=""' || '' }} ${{ matrix.variation && 'CFLAGS="-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE"' || '' }} ${{ (matrix.variation && fromJson(inputs.branch).jobs.LINUX_X64.config.variation_enable_zend_max_execution_timers) && '--enable-zend-max-execution-timers' || '' }} --${{ matrix.debug && 'enable' || 'disable' }}-debug From 9a9786600ea4aa4673cb23d38b4bbed01bdd8bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 21 Jul 2026 23:52:19 +0200 Subject: [PATCH 5/5] Fix set but not used variable --- ext/intl/grapheme/grapheme_string.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/intl/grapheme/grapheme_string.cpp b/ext/intl/grapheme/grapheme_string.cpp index 5e614be6ae72..fedfa312546e 100644 --- a/ext/intl/grapheme/grapheme_string.cpp +++ b/ext/intl/grapheme/grapheme_string.cpp @@ -1136,7 +1136,7 @@ U_CFUNC PHP_FUNCTION(grapheme_strrev) UText *ut = nullptr; UErrorCode ustatus = U_ZERO_ERROR; UBreakIterator *bi; - char *pstr, *end, *p; + char *pstr, *p; zend_string *ret; int32_t pos = 0, current = 0, end_len = 0;