Commit 7c7531bd authored by Dave Rigby's avatar Dave Rigby Committed by Facebook GitHub Bot

Mark StaticMata as FOLLY_EXPORT (#1533)

Summary:
When using folly::ThreadLocal<> to create thread-local variables, if a thread-local is set from two different libraries which are compiled with -fvisibility=hidden and using libc++, then a nullptr dereference is seen when attempting to set the thread-local from the second DLL.

This is due to StaticMetaBase (which should be a singleton) getting created twice. This results in the thread local metadata getting corrupted and hence attempting to dereference a nullptr.

Fix by marking StaticMeta as FOLLY_EXPORT, so only a single instance exists at runtime.

Fixes https://github.com/facebook/folly/issues/1431

Pull Request resolved: https://github.com/facebook/folly/pull/1533

Reviewed By: yfeldblum

Differential Revision: D26818467

Pulled By: Orvid

fbshipit-source-id: 6b22627bc51060260e653885bdeb0df111207617
parent 5a37f8c8
......@@ -393,7 +393,7 @@ struct StaticMetaBase {
// for threads that use ThreadLocalPtr objects collide on a lock inside
// StaticMeta; you can specify multiple Tag types to break that lock.
template <class Tag, class AccessMode>
struct StaticMeta final : StaticMetaBase {
struct FOLLY_EXPORT StaticMeta final : StaticMetaBase {
StaticMeta()
: StaticMetaBase(
&StaticMeta::getThreadEntrySlow,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment