зеркало из https://github.com/mozilla/pjs.git
Bug 708629. Avoid using uninitialized pkey_stack. r=bgirard
This was causing crashes with make check/xpcshell on OS X.
This commit is contained in:
Родитель
2ee5701f59
Коммит
a072f123f3
|
@ -52,6 +52,11 @@ using std::string;
|
|||
|
||||
pthread_key_t pkey_stack;
|
||||
pthread_key_t pkey_ticker;
|
||||
// We need to track whether we've been initialized otherwise
|
||||
// we end up using pkey_stack without initializing it.
|
||||
// Because pkey_stack is totally opaque to us we can't reuse
|
||||
// it as the flag itself.
|
||||
bool stack_key_initialized;
|
||||
|
||||
TimeStamp sLastTracerEvent;
|
||||
|
||||
|
@ -378,6 +383,7 @@ void mozilla_sampler_init()
|
|||
LOG("Failed to init.");
|
||||
return;
|
||||
}
|
||||
stack_key_initialized = true;
|
||||
|
||||
Stack *stack = new Stack();
|
||||
pthread_setspecific(pkey_stack, stack);
|
||||
|
|
|
@ -47,6 +47,7 @@ using mozilla::TimeDuration;
|
|||
// TODO Merge into Sampler.h
|
||||
|
||||
extern pthread_key_t pkey_stack;
|
||||
extern bool stack_key_initialized;
|
||||
|
||||
#define SAMPLER_INIT() mozilla_sampler_init();
|
||||
#define SAMPLER_DEINIT() mozilla_sampler_deinit();
|
||||
|
@ -194,7 +195,16 @@ public:
|
|||
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo)
|
||||
{
|
||||
// check if we've been initialized to avoid calling pthread_getspecific
|
||||
// with a null pkey_stack which will return undefined results.
|
||||
if (!stack_key_initialized)
|
||||
return NULL;
|
||||
|
||||
Stack *stack = (Stack*)pthread_getspecific(pkey_stack);
|
||||
// we can't infer whether 'stack' has been initialized
|
||||
// based on the value of stack_key_intiailized because
|
||||
// 'stack' is only intialized when a thread is being
|
||||
// profiled.
|
||||
if (!stack) {
|
||||
return stack;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче