runtime: don't use runtime_lock in __go_get_backtrace_state
commit5d4b7436925aee8275a6cefc7d136e9dce07d37b
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jul 2017 18:27:35 +0000 (21 18:27 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 21 Jul 2017 18:27:35 +0000 (21 18:27 +0000)
treeac8824d9cde261316f55212382c6ca9eb2255bd7
parent35ea2ff701dff37e172c75cb97440d38e3353d8f
runtime: don't use runtime_lock in __go_get_backtrace_state

    If getSiginfo does not know how to determine the PC, it will call
    runtime_callers. That can happen in a thread that was started by
    non-Go code, in which case the TLS variable g will not be set, in
    which case runtime_lock will crash.

    Avoid the problem by using atomic operations for the lock. This is OK
    since creating a backtrace state is fast and never blocks.

    The test case is TestCgoExternalThreadSIGPROF in the runtime package
    on a system that getSiginfo doesn't handle specially.

    Updates golang/go#20931

    Reviewed-on: https://go-review.googlesource.com/50650

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250439 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/go/gofrontend/MERGE
libgo/runtime/go-caller.c