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
main
Tomas Kolda 8 years ago committed by Facebook Github Bot
parent 963eeba488
commit c1fbf91b2f
  1. 7
      include/rocksdb/perf_context.h
  2. 12
      monitoring/perf_context.cc

@ -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
}

@ -14,7 +14,11 @@ namespace rocksdb {
#elif defined(_MSC_VER)
__declspec(thread) PerfContext perf_context;
#else
__thread PerfContext perf_context;
#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
}

Loading…
Cancel
Save