You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the time of writing, in the implementation of google::GetStackTrace() in src/stacktrace_libunwind-inl.h there is a global variable that enforces that only one thread may invoke libunwind at a time. However, libunwind is thread-safe. The comment above the variable declaration indicates that this is to protect against reentrancy issues:
// Sometimes, we can try to get a stack trace from within a stack// trace, because libunwind can call mmap (maybe indirectly via an// internal mmap based memory allocator), and that mmap gets trapped// and causes a stack-trace request. If were to try to honor that// recursive request, we'd end up with infinite recursion or deadlock.// Luckily, it's safe to ignore those subsequent traces. In such// cases, we return 0 to indicate the situation.staticbool g_now_entering = false;
Instead of using a global variable, it would be much better to use a thread-local variable to protect against these reentrancy issues. That should provide the needed reentrancy protection while allowing multiple threads to get stack traces at the same time. It would also allow for the removal of the atomic CAS operations on the g_now_entering variable.
The text was updated successfully, but these errors were encountered:
mpercy
added a commit
to mpercy/glog
that referenced
this issue
Jan 28, 2017
Previously, the implementation of google::GetStackTrace() that uses
libunwind uses a global variable that enforces that only one thread may
invoke libunwind at a time. However, libunwind is thread-safe. The
comment above the variable indicates that it is to protect against
reentrancy issues.
Instead of using a global variable, it would be much better to use a
thread-local variable to protect against these reentrancy issues. That
should provide the needed reentrancy protection while allowing multiple
threads to get stack traces at the same time.
It also allows for the removal of the atomic CAS operations on the
variable.
Resolvesgoogle#160.
At the time of writing, in the implementation of
google::GetStackTrace()
insrc/stacktrace_libunwind-inl.h
there is a global variable that enforces that only one thread may invoke libunwind at a time. However, libunwind is thread-safe. The comment above the variable declaration indicates that this is to protect against reentrancy issues:Instead of using a global variable, it would be much better to use a thread-local variable to protect against these reentrancy issues. That should provide the needed reentrancy protection while allowing multiple threads to get stack traces at the same time. It would also allow for the removal of the atomic CAS operations on the
g_now_entering
variable.The text was updated successfully, but these errors were encountered: