Issue #1730 - Part 1: Interpose malloc even on RTLD_DEEPBIND presence

New FreeBSD versions have introduced RTLD_DEEPBIND (see dlopen(3)), which
triggers a provoked build error to be on the "safe" side.

Indeed, improper use of RTLD_DEEPBIND could cause malloc interposing not to
work on specific libraries. This would happen for libraries that provide their
own malloc/free and exchange pointers with other libraries or the main program,
one allocating an area and another one deallocating it.

It seems it happened for glibc, which is not a concern on FreeBSD, and for the
Flash Player (not a concern either, there is no native Flash Player). Moreover,
there is only a single reference to RTLD_DEEPBIND in the whole platform
currently, namely in the WebRTC code, but the corresponding code chunk is
compiled-in only on Linux (and this library doesn't seem to redefine malloc
functions anyway). So I don't see how a problem could happen. Additionally,
Pale Moon, which is my focus, doesn't use WebRTC.

Corresponding Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=493541
This commit is contained in:
Olivier Certner 2021-02-04 22:37:10 +01:00 • committed by roytam1
commit 387487ffb6

View file

@ -6760,7 +6760,8 @@ jemalloc_darwin_init(void)
#define is_malloc_(a) malloc_is_ ## a #define is_malloc_(a) malloc_is_ ## a
#define is_malloc(a) is_malloc_(a) #define is_malloc(a) is_malloc_(a)
#if !defined(MOZ_MEMORY_DARWIN) && (is_malloc(malloc_impl) == 1) #if !(defined(MOZ_MEMORY_DARWIN) || defined(MOZ_MEMORY_BSD)) && \
(is_malloc(malloc_impl) == 1)
# if defined(__GLIBC__) && !defined(__UCLIBC__) # if defined(__GLIBC__) && !defined(__UCLIBC__)
/* /*
* glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible * glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible