Fixing Solaris Sparc crash due to cached TLS

Summary:
Workaround for Solaris gcc binary. Program is crashing, because when TLS of perf context that is used twice on same frame, it is damaged thus Segmentation fault.

Issue: #2153
Closes https://github.com/facebook/rocksdb/pull/2187

Differential Revision: D4922274

Pulled By: siying

fbshipit-source-id: 549105ebce9a8ce08a737f4d6b9f2312ebcde9a8
This commit is contained in:
Tomas Kolda 2017-04-20 10:59:04 -07:00 committed by Facebook Github Bot
parent 963eeba488
commit c1fbf91b2f
2 changed files with 17 additions and 2 deletions

View File

@ -155,7 +155,12 @@ extern PerfContext perf_context;
#elif defined(_MSC_VER)
extern __declspec(thread) PerfContext perf_context;
#else
extern __thread PerfContext perf_context;
#if defined(OS_SOLARIS)
PerfContext *getPerfContext();
#define perf_context (*getPerfContext())
#else
extern __thread PerfContext perf_context;
#endif
#endif
}

View File

@ -14,7 +14,11 @@ namespace rocksdb {
#elif defined(_MSC_VER)
__declspec(thread) PerfContext perf_context;
#else
#if defined(OS_SOLARIS)
__thread PerfContext perf_context_;
#else
__thread PerfContext perf_context;
#endif
#endif
void PerfContext::Reset() {
@ -162,4 +166,10 @@ std::string PerfContext::ToString(bool exclude_zero_counters) const {
#endif
}
#if defined(OS_SOLARIS)
PerfContext *getPerfContext() {
return &perf_context_;
}
#endif
}