X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FSingleton-inl.h;h=207a0f7dc32536b3cdf2ff11107b2598b55d2ccf;hp=2656084e81bae8abedb032d2b54ddacd815c388e;hb=68d5fb06281abea91eaa5813e0c919419cc2eb43;hpb=d51aa234a25584be0c440ace0ccf831d4a7dc51b diff --git a/folly/Singleton-inl.h b/folly/Singleton-inl.h index 2656084e..207a0f7d 100644 --- a/folly/Singleton-inl.h +++ b/folly/Singleton-inl.h @@ -224,6 +224,17 @@ void SingletonHolder::createInstance() { creating_thread_.store(std::this_thread::get_id(), std::memory_order_release); auto state = vault_.state_.rlock(); + if (vault_.type_ != SingletonVault::Type::Relaxed && + !state->registrationComplete) { + auto stack_trace_getter = SingletonVault::stackTraceGetter().load(); + auto stack_trace = stack_trace_getter ? stack_trace_getter() : ""; + if (!stack_trace.empty()) { + stack_trace = "Stack trace:\n" + stack_trace; + } + + LOG(FATAL) << "Singleton " << type().name() << " requested before " + << "registrationComplete() call. " << stack_trace; + } if (state->state == SingletonVault::SingletonVaultState::Quiescing) { return; }