|
153 | 153 | # define PHP_RTLD_MODE RTLD_LAZY
|
154 | 154 | # endif
|
155 | 155 |
|
| 156 | +# ifdef __SANITIZE_ADDRESS__ |
| 157 | +# include "sanitizer/lsan_interface.h" |
| 158 | +# endif |
| 159 | + |
| 160 | +/* dl uses a thread local variable internally. Due to LSan crashing we're setting use_tls=0, which |
| 161 | + * will report a leak inside dlopen() that we need to suppress. */ |
| 162 | +static inline void *zend_dlopen(const char *file, int mode) |
| 163 | +{ |
| 164 | +# ifdef __SANITIZE_ADDRESS__ |
| 165 | + __lsan_disable(); |
| 166 | +# endif |
| 167 | + void *ptr = dlopen(file, mode); |
| 168 | +# ifdef __SANITIZE_ADDRESS__ |
| 169 | + __lsan_enable(); |
| 170 | +# endif |
| 171 | + return ptr; |
| 172 | +} |
156 | 173 | # if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
|
157 |
| -# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT) |
| 174 | +# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT) |
158 | 175 | # elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
|
159 |
| -# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) |
| 176 | +# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND) |
160 | 177 | # else
|
161 |
| -# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL) |
| 178 | +# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL) |
162 | 179 | # endif
|
| 180 | + |
163 | 181 | # define DL_UNLOAD dlclose
|
164 | 182 | # if defined(DLSYM_NEEDS_UNDERSCORE)
|
165 | 183 | # define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
|
|
0 commit comments