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.

Change-Id: Ifb50c50aedc6faf7259757b82e11b30b867bc70d
Reviewed-by: Ian Lance Taylor <>
2 files changed