Bug 611405 part 2 - Avoid crash in nsMemoryReporterManager when jemalloc_stats is not available at runtime. r=bsmedberg,a=clegnitto

This commit is contained in:
Mike Hommey 2010-11-17 09:56:19 +01:00
parent 580a41a089
commit ffc922a1d3

View File

@ -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
*/