Skip to content

Commit 09b85da

Browse files
morrisonleviclaude
andcommitted
build: patch PHP 8.5 to disable preserve_none under ASan
preserve_none + -fsanitize=address crashes clang 19+ on x86-64 (llvm/llvm-project#95928). Apply a patch at source-tree build time that guards ZEND_PRESERVE_NONE with __has_feature(address_sanitizer), following the fix pattern from llvm-project commit 996157c. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8cc639e commit 09b85da

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Levi Morrison <levi.morrison@datadoghq.com>
3+
Date: Mon, 07 Apr 2026 00:00:00 +0000
4+
Subject: [PATCH] Disable preserve_none under ASan
5+
6+
preserve_none combined with -fsanitize=address crashes clang 19+ on
7+
x86-64. Disable it when ASan is active, following the same fix applied
8+
in llvm-project (commit 996157c).
9+
10+
See: https://github.com/llvm/llvm-project/issues/95928
11+
---
12+
Zend/zend_portability.h | 6 +++++-
13+
1 file changed, 5 insertions(+), 1 deletion(-)
14+
15+
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
16+
index 1111111..2222222 100644
17+
--- a/Zend/zend_portability.h
18+
+++ b/Zend/zend_portability.h
19+
@@ -333,7 +333,11 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
20+
21+
#ifdef HAVE_PRESERVE_NONE
22+
-# define ZEND_PRESERVE_NONE __attribute__((preserve_none))
23+
+# if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
24+
+/* preserve_none + ASan crashes clang 19+ on x86-64, see llvm/llvm-project#95928 */
25+
+# define ZEND_PRESERVE_NONE
26+
+# else
27+
+# define ZEND_PRESERVE_NONE __attribute__((preserve_none))
28+
+# endif
29+
#endif

dockerfiles/ci/bookworm/php-8.5/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ COPY php-8.5/suppr.txt /home/circleci/suppr.txt
1010
FROM --platform=$BUILDPLATFORM $BUILD_BASE AS src
1111
ARG phpTarGzUrl
1212
ARG phpSha256Hash
13+
COPY php-8.5/0001-Disable-preserve_none-under-ASan.patch /home/circleci
1314
RUN set -eux; \
1415
curl -fsSL -o /tmp/php.tar.gz "${phpTarGzUrl}"; \
1516
(echo "${phpSha256Hash} /tmp/php.tar.gz" | sha256sum -c -); \
1617
tar xf /tmp/php.tar.gz -C "${PHP_SRC_DIR}" --strip-components=1; \
1718
rm -f /tmp/php.tar.gz; \
1819
cd ${PHP_SRC_DIR}; \
20+
git apply /home/circleci/0001-Disable-preserve_none-under-ASan.patch; \
1921
# We need to remove the dl() calls from run-tests as some extensions don't properly switch interned string storage for INIs. \
2022
sed -i 's/\bdl(/(bool)(/' run-tests.php; \
2123
./buildconf --force;

0 commit comments

Comments
 (0)