Skip to content

Commit

Permalink
Disable RTLD_DEEPBIND when compiling with AddressSanitizer (-fsanitiz…
Browse files Browse the repository at this point in the history
…e=address).

The AddressSanitizer doesn't support RTLD_DEEPBIND resulting in
erratic errors when deinitializing phar module and possibly others.

Clang use __has_feature() macro to indicate compilation with
AddressSanitizer while gcc uses __SANITIZE_ADDRESS__ define.

Fixes bug #73677.
  • Loading branch information
oerdnj authored and nikic committed Feb 16, 2017
1 parent cf3ef36 commit 61e59db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ PHP NEWS
get_object_vars). (mhagstrand)
. Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
. Fixed bug #74039 (is_infinite(-INF) returns false). (Christian Schmidt)
. Fixed bug #73677 (Generating phar.phar core dump with gcc ASAN enabled
build). (ondrej)

- Apache:
. Fixed bug #61471 (Incomplete POST does not timeout but is passed to PHP).
Expand Down
8 changes: 7 additions & 1 deletion Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@

#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)

# if defined(__has_feature)
# if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__
# endif
# endif

# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
# endif
Expand All @@ -141,7 +147,7 @@

# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# elif defined(RTLD_DEEPBIND)
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
# else
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
Expand Down

0 comments on commit 61e59db

Please sign in to comment.