From e20bfbd18e64b8ab9428aa518b5d7b74a73461d9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 29 Dec 2018 00:07:06 +0000 Subject: runtime: prevent deadlock when profiling signal arrives in stack scan Precise stack scan needs to unwind the stack. When it is unwinding the stack, if a profiling signal arrives, which also does a traceback, it may deadlock in dl_iterate_phdr. Prevent this deadlock by setting up runtime_in_callers before traceback. Reviewed-on: https://go-review.googlesource.com/c/155766 From-SVN: r267457 --- libgo/runtime/go-unwind.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libgo/runtime/go-unwind.c') diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c index 58cb270..158cbd0 100644 --- a/libgo/runtime/go-unwind.c +++ b/libgo/runtime/go-unwind.c @@ -792,7 +792,9 @@ bool scanstackwithmap (void *gcw) { _Unwind_Reason_Code code; + runtime_xadd (&__go_runtime_in_callers, 1); code = _Unwind_Backtrace (scanstackwithmap_callback, gcw); + runtime_xadd (&__go_runtime_in_callers, -1); return code == _URC_END_OF_STACK; } -- cgit v1.1