From 387487ffb6af3278ac6961d87817ac13eedf7a21 Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 4 Feb 2021 22:37:10 +0100 Subject: [PATCH] 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 --- memory/mozjemalloc/jemalloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c index 4461b9c44b..71e568a0eb 100644 --- a/memory/mozjemalloc/jemalloc.c +++ b/memory/mozjemalloc/jemalloc.c @@ -6760,7 +6760,8 @@ jemalloc_darwin_init(void) #define is_malloc_(a) malloc_is_ ## 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__) /* * glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible