From: Austin Clements Date: Fri, 14 Oct 2022 19:36:58 +0000 (-0400) Subject: runtime: improve coverage of TestCgoSigfwd X-Git-Tag: go1.20rc1~617 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a81da928b4891f111e40dfca677d3c90d1411f0d;p=gostls13.git runtime: improve coverage of TestCgoSigfwd Currently, TestCgoSigfwd will pass incorrectly if the SIGSEGV that originates in Go mistakenly goes to the C SIGSEGV handler. Fix this by adding a signal-atomic variable that tracks what the expected behavior is. Change-Id: Id2a9fa3b209299dccf90bb60720b89ad96838a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/443072 Run-TryBot: Austin Clements Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot --- diff --git a/src/runtime/testdata/testprogcgo/sigfwd.go b/src/runtime/testdata/testprogcgo/sigfwd.go index 1694289700..b27d436f82 100644 --- a/src/runtime/testdata/testprogcgo/sigfwd.go +++ b/src/runtime/testdata/testprogcgo/sigfwd.go @@ -17,8 +17,11 @@ import ( #include #include +sig_atomic_t expectCSigsegv; int *sigfwdP; + static void sigsegv() { + expectCSigsegv = 1; *sigfwdP = 1; fprintf(stderr, "ERROR: C SIGSEGV not thrown on caught?.\n"); exit(2); @@ -26,6 +29,10 @@ static void sigsegv() { static void segvhandler(int signum) { if (signum == SIGSEGV) { + if (expectCSigsegv == 0) { + fprintf(stderr, "SIGSEGV caught in C unexpectedly\n"); + exit(1); + } fprintf(stdout, "OK\n"); exit(0); // success }