aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/testdata
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2021-08-04 11:24:28 -0400
committerMichael Pratt <mpratt@google.com>2021-10-26 21:17:38 +0000
commit091db6392da5913e4bd4806215102e461dc5649c (patch)
treee250f5d5bc183388f465efdb5b42f341c55a9694 /src/runtime/testdata
parent3a0cd1121413ad02172784114318ac6b0c2801c1 (diff)
downloadgo-091db6392da5913e4bd4806215102e461dc5649c.tar.xz
runtime: fix cgo signals detection
CL 64070 removed lockOSThread from the cgocall path, but didn't update the signal-in-cgo detection in sighandler. As a result, signals that arrive during a cgo call are treated like they arrived during Go execution, breaking the traceback. Update the cgo detection to fix the backtrace. Fixes #47522 Change-Id: I61d77ba6465f55e3e6187246d79675ba8467ec23 Reviewed-on: https://go-review.googlesource.com/c/go/+/339989 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/testdata')
-rw-r--r--src/runtime/testdata/testprogcgo/panic.go29
-rw-r--r--src/runtime/testdata/testprogcgo/sigthrow.go20
2 files changed, 49 insertions, 0 deletions
diff --git a/src/runtime/testdata/testprogcgo/panic.go b/src/runtime/testdata/testprogcgo/panic.go
new file mode 100644
index 0000000000..4ddef3abcd
--- /dev/null
+++ b/src/runtime/testdata/testprogcgo/panic.go
@@ -0,0 +1,29 @@
+package main
+
+import "C"
+
+// This program will crash.
+// We want to test unwinding from a cgo callback.
+
+/*
+void panic_callback();
+
+static void call_callback(void) {
+ panic_callback();
+}
+*/
+import "C"
+
+func init() {
+ register("PanicCallback", PanicCallback)
+}
+
+//export panic_callback
+func panic_callback() {
+ var i *int
+ *i = 42
+}
+
+func PanicCallback() {
+ C.call_callback()
+}
diff --git a/src/runtime/testdata/testprogcgo/sigthrow.go b/src/runtime/testdata/testprogcgo/sigthrow.go
new file mode 100644
index 0000000000..665e3b02df
--- /dev/null
+++ b/src/runtime/testdata/testprogcgo/sigthrow.go
@@ -0,0 +1,20 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+// This program will abort.
+
+/*
+#include <stdlib.h>
+*/
+import "C"
+
+func init() {
+ register("Abort", Abort)
+}
+
+func Abort() {
+ C.abort()
+}