Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Comments

Use thread local for libunwind GetStackTrace() reentrancy protection#161

Merged
sergiud merged 1 commit intogoogle:masterfrom
mpercy:thread-local-libunwind-2
Oct 31, 2019
Merged

Use thread local for libunwind GetStackTrace() reentrancy protection#161
sergiud merged 1 commit intogoogle:masterfrom
mpercy:thread-local-libunwind-2

Conversation

@mpercy
Copy link
Contributor

@mpercy mpercy commented 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.

Resolves #160.

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.

Resolves google#160.
@sergiud sergiud merged commit f17d11a into google:master Oct 31, 2019
@sergiud sergiud added this to the 0.5 milestone Apr 13, 2021
@sergiud sergiud mentioned this pull request May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stacktrace_libunwind-inl.h: reentrancy check should use a thread-local instead of a global variable

3 participants