From ffc922a1d33fbc8505a8ed15d1632d2dc134d5ad Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 17 Nov 2010 09:56:19 +0100 Subject: [PATCH] Bug 611405 part 2 - Avoid crash in nsMemoryReporterManager when jemalloc_stats is not available at runtime. r=bsmedberg,a=clegnitto --- xpcom/base/nsMemoryReporterManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 72d72c099f8..03694bdfbe3 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -59,10 +59,6 @@ // with it. So if we tried to use jemalloc_stats directly here, it // wouldn't be defined. Instead, we don't include the jemalloc header // and weakly link against jemalloc_stats. -// -// NB: we don't null-check this symbol at runtime because we expect it -// to have been resolved. If it hasn't, the crash jumping to NULL -// will indicate the bug. extern "C" { extern void jemalloc_stats(jemalloc_stats_t* stats) NS_VISIBILITY_DEFAULT __attribute__((weak)); @@ -219,6 +215,10 @@ NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager) NS_IMETHODIMP nsMemoryReporterManager::Init() { +#if HAVE_JEMALLOC_STATS && defined(XP_LINUX) + if (!jemalloc_stats) + return NS_ERROR_FAILURE; +#endif /* * Register our core reporters */