Bug 1279614 - 2,000 instances of "XPCOM objects created/destroyed from static ctor/dtor" emitted from xpcom/base/nsTraceRefcnt.cpp during linux64 debug testing. r=gfritzsche,jmathies.

This commit is contained in:
Julian Seward 2016-06-30 14:04:15 +02:00
parent 848fd91f64
commit 731eb09566
3 changed files with 29 additions and 15 deletions

View File

@ -165,8 +165,8 @@ namespace {
// Set to true once this global state has been initialized
bool gInitDone = false;
bool gCanRecordBase;
bool gCanRecordExtended;
bool gCanRecordBase = false;
bool gCanRecordExtended = false;
HistogramMapType gHistogramMap(mozilla::Telemetry::HistogramCount);

View File

@ -4420,6 +4420,15 @@ void XRE_GlibInit()
}
#endif
// Separate stub function to let us specifically suppress it in Valgrind
void
XRE_CreateStatsObject()
{
// Initialize global variables used by histogram collection
// machinery that is used by by Telemetry. Note: is never de-initialised.
Telemetry::CreateStatisticsRecorder();
}
/*
* XRE_main - A class based main entry point used by most platforms.
* Note that on OSX, aAppData->xreDirectory will point to
@ -4430,6 +4439,16 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
{
ScopedLogging log;
// NB: this must happen after the creation of |ScopedLogging log| since
// ScopedLogging::ScopedLogging calls NS_LogInit, and
// XRE_CreateStatsObject calls Telemetry::CreateStatisticsRecorder,
// and NS_LogInit must be called before Telemetry::CreateStatisticsRecorder.
// NS_LogInit must be called before Telemetry::CreateStatisticsRecorder
// so as to avoid many log messages of the form
// WARNING: XPCOM objects created/destroyed from static ctor/dtor: [..]
// See bug 1279614.
XRE_CreateStatsObject();
#if defined(MOZ_SANDBOX) && defined(XP_LINUX) && !defined(ANDROID)
SandboxInfo::ThreadingCheck();
#endif
@ -4581,21 +4600,11 @@ XRE_StopLateWriteChecks(void) {
mozilla::StopLateWriteChecks();
}
// Separate stub function to let us specifically suppress it in Valgrind
void
XRE_CreateStatsObject()
{
// Initialize global variables used by histogram collection
// machinery that is used by by Telemetry. Note: is never de-initialised.
Telemetry::CreateStatisticsRecorder();
}
int
XRE_main(int argc, char* argv[], const nsXREAppData* aAppData, uint32_t aFlags)
{
XREMain main;
XRE_CreateStatsObject();
int result = main.XRE_main(argc, argv, aAppData);
mozilla::RecordShutdownEndTimeStamp();
return result;

View File

@ -317,9 +317,6 @@ XRE_InitChildProcess(int aArgc,
setupProfilingStuff();
#endif
// This is needed by Telemetry to initialize histogram collection.
Telemetry::CreateStatisticsRecorder();
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK)
// On non-Fennec Gecko, the GMPLoader code resides in plugin-container,
// and we must forward it through to the GMP code here.
@ -365,6 +362,14 @@ XRE_InitChildProcess(int aArgc,
// NB: This must be called before profiler_init
NS_LogInit();
// This is needed by Telemetry to initialize histogram collection.
// NB: This must be called after NS_LogInit().
// NS_LogInit must be called before Telemetry::CreateStatisticsRecorder
// so as to avoid many log messages of the form
// WARNING: XPCOM objects created/destroyed from static ctor/dtor: [..]
// See bug 1279614.
Telemetry::CreateStatisticsRecorder();
mozilla::LogModule::Init();
char aLocal;