From 172e5c152c6c4d193f995f0cfc24258344b6f63d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 2 Sep 2024 15:59:25 +0200 Subject: [PATCH 1/5] Build 32-bit with asan --- .github/workflows/push.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 086c5cc0347b..f082b1044d0b 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -43,7 +43,7 @@ env: CXX: ccache g++ jobs: LINUX_X64: - if: github.repository == 'php/php-src' || github.event_name == 'pull_request' + if: false services: mysql: image: mysql:8.3 @@ -180,6 +180,8 @@ jobs: configurationParameters: >- --enable-debug --enable-zts + --enable-address-sanitizer + --enable-undefined-sanitizer - name: make run: make -j$(/usr/bin/nproc) >/dev/null - name: make install @@ -191,8 +193,9 @@ jobs: runTestsParameters: >- -d zend_extension=opcache.so -d opcache.enable_cli=1 + --asan MACOS_DEBUG_NTS: - if: github.repository == 'php/php-src' || github.event_name == 'pull_request' + if: false strategy: fail-fast: false matrix: @@ -234,7 +237,7 @@ jobs: - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files WINDOWS: - if: github.repository == 'php/php-src' || github.event_name == 'pull_request' + if: false name: WINDOWS_X64_ZTS runs-on: windows-2022 env: @@ -261,7 +264,7 @@ jobs: run: .github/scripts/windows/test.bat BENCHMARKING: name: BENCHMARKING - if: github.repository == 'php/php-src' || github.event_name == 'pull_request' + if: false runs-on: ubuntu-22.04 steps: - name: git checkout From 38691b04f3283f92b70b3522c87cfbcdb60d8d8e Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 2 Sep 2024 17:24:52 +0200 Subject: [PATCH 2/5] Fix alignment in mysqli --- ext/mysqlnd/mysqlnd_portability.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index 11ebf4d1bf8a..0ce146ca6956 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -120,7 +120,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ ((uint32_t) (zend_uchar) (A)[0]))) #define sint4korr(A) (*((zend_long *) (A))) -#define uint2korr(A) (*((uint16_t *) (A))) +#define uint2korr(A) (((uint16_t)(A)[0]) + (((uint16_t)(A)[1]) << 8)) #define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ (((uint32_t) ((zend_uchar) (A)[2])) << 16)) From 1a50f550deed0275acd24acc7484c8188263439d Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 2 Sep 2024 17:25:47 +0200 Subject: [PATCH 3/5] Fix signed overflow in gd --- ext/gd/libgd/gd_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/gd/libgd/gd_filter.c b/ext/gd/libgd/gd_filter.c index db364c923ec6..0744c66b8f86 100644 --- a/ext/gd/libgd/gd_filter.c +++ b/ext/gd/libgd/gd_filter.c @@ -21,9 +21,9 @@ #define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel) #ifdef _WIN32 -# define GD_SCATTER_SEED() (unsigned int)(time(0) * GetCurrentProcessId()) +# define GD_SCATTER_SEED() ((unsigned int)time(0) * (unsigned int)GetCurrentProcessId()) #else -# define GD_SCATTER_SEED() (unsigned int)(time(0) * getpid()) +# define GD_SCATTER_SEED() ((unsigned int)time(0) * (unsigned int)getpid()) #endif int gdImageScatter(gdImagePtr im, int sub, int plus) From fa8e8adb8310cf204bbed90c655c6f1f61cba13b Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 2 Sep 2024 18:36:33 +0200 Subject: [PATCH 4/5] Fix mysqli again --- ext/mysqlnd/mysqlnd_portability.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index 0ce146ca6956..77184463afc6 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -124,7 +124,10 @@ This file is public domain and comes with NO WARRANTY of any kind */ #define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ (((uint32_t) ((zend_uchar) (A)[2])) << 16)) -#define uint4korr(A) (*((zend_ulong *) (A))) +#define uint4korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ + (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ + (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\ + (((uint32_t) ((zend_uchar) (A)[3])) << 24)) From 0db83f5fc8fb99f10ea54af79c62bdf2b68aa840 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Tue, 3 Sep 2024 11:18:53 +0200 Subject: [PATCH 5/5] Disable mysql bit fetching optimizations Ignoring alignment can lead to bus errors. --- ext/mysqlnd/mysqlnd_portability.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/mysqlnd/mysqlnd_portability.h b/ext/mysqlnd/mysqlnd_portability.h index 77184463afc6..7bbd33d27d3b 100644 --- a/ext/mysqlnd/mysqlnd_portability.h +++ b/ext/mysqlnd/mysqlnd_portability.h @@ -108,7 +108,7 @@ This file is public domain and comes with NO WARRANTY of any kind */ */ /* Optimized store functions for Intel x86, non-valid for WIN64. __i386__ is GCC */ -#if defined(__i386__) && !defined(_WIN64) +#if 0 #define sint2korr(A) (*((int16_t *) (A))) #define sint3korr(A) ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \ (((uint32_t) 255L << 24) | \ @@ -120,14 +120,11 @@ This file is public domain and comes with NO WARRANTY of any kind */ ((uint32_t) (zend_uchar) (A)[0]))) #define sint4korr(A) (*((zend_long *) (A))) -#define uint2korr(A) (((uint16_t)(A)[0]) + (((uint16_t)(A)[1]) << 8)) +#define uint2korr(A) (*((uint16_t *) (A))) #define uint3korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ (((uint32_t) ((zend_uchar) (A)[2])) << 16)) -#define uint4korr(A) (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\ - (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\ - (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\ - (((uint32_t) ((zend_uchar) (A)[3])) << 24)) +#define uint4korr(A) (*((zend_ulong *) (A)))