diff options
author | Austin Clements <austin@google.com> | 2018-01-30 16:03:51 -0500 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-01-31 02:13:21 +0000 |
commit | ebe38b867c869108ecf06b7d2e3664bb9d996275 (patch) | |
tree | e7e4fcc901e17668d7588e8ad0c2f12609c41d78 /src/runtime/crash_cgo_test.go | |
parent | 5c2be42a687492d2538489de69c50d66fd3dadee (diff) | |
download | go-ebe38b867c869108ecf06b7d2e3664bb9d996275.tar.gz go-ebe38b867c869108ecf06b7d2e3664bb9d996275.zip |
runtime: fail silently if we unwind over sigpanic into C code
If we're running C code and the code panics, the runtime will inject a
call to sigpanic into the C code just like it would into Go code.
However, the return PC from this sigpanic will be in C code. We used
to silently abort the traceback if we didn't recognize a return PC, so
this went by quietly. Now we're much louder because in general this is
a bad thing. However, in this one particular case, it's fine, so if
we're in cgo and are looking at the return PC of sigpanic, silence the
debug output.
Fixes #23576.
Change-Id: I03d0c14d4e4d25b29b1f5804f5e9ccc4f742f876
Reviewed-on: https://go-review.googlesource.com/90896
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/crash_cgo_test.go')
-rw-r--r-- | src/runtime/crash_cgo_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 8993a75ad3..3b9fedc7a4 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -481,3 +481,24 @@ func TestSigStackSwapping(t *testing.T) { t.Errorf("expected %q got %v", want, got) } } + +func TestCgoTracebackSigpanic(t *testing.T) { + // Test unwinding over a sigpanic in C code without a C + // symbolizer. See issue #23576. + if runtime.GOOS == "windows" { + // On Windows if we get an exception in C code, we let + // the Windows exception handler unwind it, rather + // than injecting a sigpanic. + t.Skip("no sigpanic in C on windows") + } + t.Parallel() + got := runTestProg(t, "testprogcgo", "TracebackSigpanic") + want := "runtime.sigpanic" + if !strings.Contains(got, want) { + t.Fatalf("want failure containing %q. output:\n%s\n", want, got) + } + nowant := "unexpected return pc" + if strings.Contains(got, nowant) { + t.Fatalf("failure incorrectly contains %q. output:\n%s\n", nowant, got) + } +} |