aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-callers.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-01-05 00:40:04 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-01-05 00:40:04 +0000
commitf6be1179bb66624403d0f55620d67344d9d98c51 (patch)
tree29cb9bb891a22723eb9b089c40e3f32bff282e09 /libgo/runtime/go-callers.c
parent869fbd357e1936b0c1239bc2a336de34fd45b79e (diff)
downloadgcc-f6be1179bb66624403d0f55620d67344d9d98c51.zip
gcc-f6be1179bb66624403d0f55620d67344d9d98c51.tar.gz
gcc-f6be1179bb66624403d0f55620d67344d9d98c51.tar.bz2
runtime: prevent deadlock when profiling signal arrives during traceback
Traceback routines, e.g. callers and funcentry, may call __go_get_backtrace_state. If a profiling signal arrives while we are in the critical section of __go_get_backtrace_state, it tries to do a traceback, which also calls __go_get_backtrace_state, which tries to enter the same critical section and will deadlock. Prevent this deadlock by setting up runtime_in_callers before calling __go_get_backtrace_state. Found while investigating golang/go#29448. Will add a test in the next CL. Updates golang/go#29448. Reviewed-on: https://go-review.googlesource.com/c/156037 From-SVN: r267590
Diffstat (limited to 'libgo/runtime/go-callers.c')
-rw-r--r--libgo/runtime/go-callers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c
index 78ada7a..7ea70851 100644
--- a/libgo/runtime/go-callers.c
+++ b/libgo/runtime/go-callers.c
@@ -202,8 +202,8 @@ runtime_callers (int32 skip, Location *locbuf, int32 m, bool keep_thunks)
data.index = 0;
data.max = m;
data.keep_thunks = keep_thunks;
- state = __go_get_backtrace_state ();
runtime_xadd (&__go_runtime_in_callers, 1);
+ state = __go_get_backtrace_state ();
backtrace_full (state, 0, callback, error_callback, &data);
runtime_xadd (&__go_runtime_in_callers, -1);