Skip to content

Disable LSan tls #11995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/actions/apt-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ runs:
run: |
set -x

echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | \
sudo tee -a /etc/apt/sources.list.d/ddebs.list
sudo apt-get install ubuntu-dbgsym-keyring

sudo apt-get update
sudo apt-get install \
bison \
Expand Down Expand Up @@ -45,8 +51,6 @@ runs:
snmp-mibs-downloader \
freetds-dev \
unixodbc-dev \
llvm \
clang \
libc-client-dev \
dovecot-core \
dovecot-pop3d \
Expand Down
1 change: 0 additions & 1 deletion .github/actions/configure-x64/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,4 @@ runs:
--with-config-file-scan-dir=/etc/php.d \
${{ inputs.skipSlow == 'false' && '--with-pdo-firebird' || '' }} \
${{ inputs.skipSlow == 'false' && '--with-pdo-dblib' || '' }} \
--enable-werror \
${{ inputs.configurationParameters }}
6 changes: 5 additions & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
uses: ./.github/actions/setup-caddy
- name: apt
uses: ./.github/actions/apt-x64
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "16.0"
- name: ccache
uses: hendrikmuhs/[email protected]
with:
Expand All @@ -80,7 +84,7 @@ jobs:
configurationParameters: >-
--${{ matrix.debug && 'enable' || 'disable' }}-debug
--${{ matrix.zts && 'enable' || 'disable' }}-zts
${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address" CC=clang CXX=clang++ --disable-opcache-jit' || '' }}
${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC -fno-omit-frame-pointer" LDFLAGS="-fsanitize=undefined,address" CC=clang CXX=clang++ --disable-opcache-jit' || '' }}
skipSlow: ${{ matrix.asan }}
- name: make
run: make -j$(/usr/bin/nproc) >/dev/null
Expand Down
39 changes: 34 additions & 5 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,47 @@
# define PHP_RTLD_MODE RTLD_LAZY
# endif

# ifdef __SANITIZE_ADDRESS__
# include "sanitizer/lsan_interface.h"
# endif

/* dl uses a thread local variable internally. Due to LSan crashing we're setting use_tls=0, which
* will report a leak inside dlopen() that we need to suppress. */
static inline void *zend_dlopen(const char *file, int mode)
{
# ifdef __SANITIZE_ADDRESS__
__lsan_disable();
# endif
void *ptr = dlopen(file, mode);
# ifdef __SANITIZE_ADDRESS__
__lsan_enable();
# endif
return ptr;
}
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
# else
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
# define DL_LOAD(libname) zend_dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
# endif

static inline void *zend_dlsym(void *__restrict handle, const char *__restrict name)
{
# ifdef __SANITIZE_ADDRESS__
__lsan_disable();
# endif
void *ptr = dlsym(handle, name);
# ifdef __SANITIZE_ADDRESS__
__lsan_enable();
# endif
return ptr;
}
# define DL_UNLOAD dlclose
# if defined(DLSYM_NEEDS_UNDERSCORE)
# define DL_FETCH_SYMBOL(h,s) dlsym((h), "_" s)
# define DL_FETCH_SYMBOL(h,s) zend_dlsym((h), "_" s)
# else
# define DL_FETCH_SYMBOL dlsym
# define DL_FETCH_SYMBOL zend_dlsym
# endif
# define DL_ERROR dlerror
# define DL_HANDLE void *
Expand Down
2 changes: 1 addition & 1 deletion ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ this extension sharedto offer compatibility.
do { \
(cb) = NULL; \
cli_shell_callbacks_t *(*get_callbacks)(void); \
get_callbacks = dlsym(RTLD_DEFAULT, "php_cli_get_shell_callbacks"); \
get_callbacks = DL_FETCH_SYMBOL(RTLD_DEFAULT, "php_cli_get_shell_callbacks"); \
if (get_callbacks) { \
(cb) = get_callbacks(); \
} \
Expand Down
2 changes: 1 addition & 1 deletion run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ function main(): void
$lsanSuppressions = __DIR__ . '/.github/lsan-suppressions.txt';
if (file_exists($lsanSuppressions)) {
$environment['LSAN_OPTIONS'] = 'suppressions=' . $lsanSuppressions
. ':print_suppressions=0';
. ':print_suppressions=0:use_tls=0:fast_unwind_on_malloc=false';
}
break;
case '--repeat':
Expand Down