Skip to content

Commit c8c5a3a

Browse files
committed
Fixed bug #77447
By disabling asan for CPU support helpers used in ifunc resolvers.
1 parent 9204505 commit c8c5a3a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ PHP NEWS
1414
. Fixed bug #77317 (__DIR__, __FILE__, realpath() reveal physical path for
1515
subst virtual drive). (Anatol)
1616
. Fixed bug #77263 (Segfault when using 2 RecursiveFilterIterator). (Dmitry)
17+
. Fixed bug #77447 (PHP 7.3 built with ASAN crashes in
18+
zend_cpu_supports_avx2). (Nikita)
1719

1820
- Fileinfo:
1921
. Fixed bug #77346 (webm files incorrectly detected as

Zend/zend_cpuinfo.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,54 +100,70 @@ typedef enum _zend_cpu_feature {
100100
void zend_cpu_startup();
101101
ZEND_API int zend_cpu_supports(zend_cpu_feature feature);
102102

103+
/* Address sanitizer is incompatible with ifunc resolvers, so exclude the
104+
* CPU support helpers from asan.
105+
* See also https://github.com/google/sanitizers/issues/342. */
106+
#if __has_attribute(no_sanitize_address)
107+
# define ZEND_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
108+
#else
109+
# define ZEND_NO_SANITIZE_ADDRESS
110+
#endif
111+
103112
#if PHP_HAVE_BUILTIN_CPU_SUPPORTS
104113
/* NOTE: you should use following inline function in
105114
* resolver functions (ifunc), as it could be called
106115
* before all PLT symbols are resloved. in other words,
107116
* resolver functions should not depends any external
108117
* functions */
118+
ZEND_NO_SANITIZE_ADDRESS
109119
static zend_always_inline int zend_cpu_supports_sse2() {
110120
#if PHP_HAVE_BUILTIN_CPU_INIT
111121
__builtin_cpu_init();
112122
#endif
113123
return __builtin_cpu_supports("sse2");
114124
}
115125

126+
ZEND_NO_SANITIZE_ADDRESS
116127
static zend_always_inline int zend_cpu_supports_sse3() {
117128
#if PHP_HAVE_BUILTIN_CPU_INIT
118129
__builtin_cpu_init();
119130
#endif
120131
return __builtin_cpu_supports("sse3");
121132
}
122133

134+
ZEND_NO_SANITIZE_ADDRESS
123135
static zend_always_inline int zend_cpu_supports_ssse3() {
124136
#if PHP_HAVE_BUILTIN_CPU_INIT
125137
__builtin_cpu_init();
126138
#endif
127139
return __builtin_cpu_supports("ssse3");
128140
}
129141

142+
ZEND_NO_SANITIZE_ADDRESS
130143
static zend_always_inline int zend_cpu_supports_sse41() {
131144
#if PHP_HAVE_BUILTIN_CPU_INIT
132145
__builtin_cpu_init();
133146
#endif
134147
return __builtin_cpu_supports("sse4.1");
135148
}
136149

150+
ZEND_NO_SANITIZE_ADDRESS
137151
static zend_always_inline int zend_cpu_supports_sse42() {
138152
#if PHP_HAVE_BUILTIN_CPU_INIT
139153
__builtin_cpu_init();
140154
#endif
141155
return __builtin_cpu_supports("sse4.2");
142156
}
143157

158+
ZEND_NO_SANITIZE_ADDRESS
144159
static zend_always_inline int zend_cpu_supports_avx() {
145160
#if PHP_HAVE_BUILTIN_CPU_INIT
146161
__builtin_cpu_init();
147162
#endif
148163
return __builtin_cpu_supports("avx");
149164
}
150165

166+
ZEND_NO_SANITIZE_ADDRESS
151167
static zend_always_inline int zend_cpu_supports_avx2() {
152168
#if PHP_HAVE_BUILTIN_CPU_INIT
153169
__builtin_cpu_init();

0 commit comments

Comments
 (0)