From 3da4281df1b0c7ea11b524ff19fc2f409b8e58c0 Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Mon, 9 Sep 2024 09:01:23 +0000 Subject: runtime: Goexit on C-created thread report more useful error message Fixes #68275 Change-Id: I47b7a2092f1b4d48aebf437db4e329815c956bb9 GitHub-Last-Rev: b89bf3cab7f9f7611122f535914f2788564643c5 GitHub-Pull-Request: golang/go#69126 Reviewed-on: https://go-review.googlesource.com/c/go/+/609296 Reviewed-by: Tim King LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor --- src/runtime/testdata/testprogcgo/callback.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/runtime/testdata') diff --git a/src/runtime/testdata/testprogcgo/callback.go b/src/runtime/testdata/testprogcgo/callback.go index 319572fe10..39993f13a6 100644 --- a/src/runtime/testdata/testprogcgo/callback.go +++ b/src/runtime/testdata/testprogcgo/callback.go @@ -38,10 +38,21 @@ import ( func init() { register("CgoCallbackGC", CgoCallbackGC) + register("CgoToGoCallGoexit", CgoToGoCallGoexit) } +func CgoToGoCallGoexit() { + goexit = true + C.foo() +} + +var goexit = false + //export go_callback func go_callback() { + if goexit { + runtime.Goexit() + } if e := extraMInUse.Load(); e == 0 { fmt.Printf("in callback extraMInUse got %d want >0\n", e) os.Exit(1) -- cgit v1.3