From a4eda9d3a960b35fbf1d5a3d4ac028a604637313 Mon Sep 17 00:00:00 2001 From: Subodh Iyengar Date: Wed, 15 Oct 2014 16:51:46 -0700 Subject: [PATCH] Remove global init of ThreadLocal in Random Summary: Remove global initialization of ThreadLocal in Random See https://gcc.gnu.org/onlinedocs/gcc-4.8.3/gcc/Thread-Local.html Static initializers and thread locals don't mix well, and we're seeing some crashes which we think might be related to this. Test Plan: Unit tests Reviewed By: seanc@fb.com Subscribers: trunkagent, seanc, njormrod FB internal diff: D1617455 --- folly/Random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/folly/Random.cpp b/folly/Random.cpp index 06b3d5ae..f18d6f33 100644 --- a/folly/Random.cpp +++ b/folly/Random.cpp @@ -90,11 +90,11 @@ void BufferedRandomDevice::getSlow(unsigned char* data, size_t size) { ptr_ += size; } -ThreadLocal bufferedRandomDevice; } // namespace void Random::secureRandom(void* data, size_t size) { + static ThreadLocal bufferedRandomDevice; bufferedRandomDevice->get(data, size); } -- 2.34.1