From: Subodh Iyengar Date: Wed, 15 Oct 2014 23:51:46 +0000 (-0700) Subject: Remove global init of ThreadLocal in Random X-Git-Tag: v0.22.0~271 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a4eda9d3a960b35fbf1d5a3d4ac028a604637313;p=folly.git 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 --- 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); }