[go] cmd/go: test with SIGTERM in test_fuzz_non_crash_signal

65 views
Skip to first unread message

Bryan C. Mills (Gerrit)

unread,
Oct 28, 2021, 4:00:38 PM10/28/21
to goph...@pubsubhelper.golang.org, Bryan C. Mills, golang-co...@googlegroups.com

Bryan C. Mills has uploaded this change for review.

View Change

cmd/go: test with SIGTERM in test_fuzz_non_crash_signal

The test currently uses only SIGKILL (which cannot be trapped by the
worker process) and SIGILL (which is handled by the Go runtime, and
does pretty unambiguously indicate a crash). It is missing a third
(and perhaps more likely) case: a signal like SIGTERM that is handled
by the Go runtime and causes the test to terminate, but nonetheless
does not indicate a crash.

Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f
---
M src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt
1 file changed, 36 insertions(+), 0 deletions(-)

diff --git a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt
index f1a4c66..31d54bc 100644
--- a/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt
+++ b/src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt
@@ -10,6 +10,15 @@
! exists testdata
! stdout unreachable
! stderr unreachable
+stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: terminated'
+
+# FuzzKill sends itself a signal that cannot be caught by the worker process
+# and does not appear to be a crash.
+# We should not save a crasher.
+! go test -fuzz=FuzzKill
+! exists testdata
+! stdout unreachable
+! stderr unreachable
stdout 'fuzzing process terminated by unexpected signal; no crash will be recorded: signal: killed'

# FuzzCrash sends itself a signal that looks like a crash.
@@ -35,6 +44,17 @@
func FuzzNonCrash(f *testing.F) {
f.Fuzz(func(*testing.T, bool) {
pid := syscall.Getpid()
+ if err := syscall.Kill(pid, syscall.SIGTERM); err != nil {
+ panic(err)
+ }
+ // signal may not be received immediately. Wait for it.
+ select{}
+ })
+}
+
+func FuzzKill(f *testing.F) {
+ f.Fuzz(func(*testing.T, bool) {
+ pid := syscall.Getpid()
if err := syscall.Kill(pid, syscall.SIGKILL); err != nil {
panic(err)
}

To view, visit change 359482. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f
Gerrit-Change-Number: 359482
Gerrit-PatchSet: 1
Gerrit-Owner: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
Gerrit-MessageType: newchange

Katie Hockman (Gerrit)

unread,
Oct 28, 2021, 4:25:16 PM10/28/21
to Bryan C. Mills, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Bryan C. Mills.

Patch set 1:Run-TryBot +1Code-Review +2Trust +1

View Change

1 comment:

To view, visit change 359482. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f
Gerrit-Change-Number: 359482
Gerrit-PatchSet: 1
Gerrit-Owner: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Katie Hockman <ka...@golang.org>
Gerrit-Attention: Bryan C. Mills <bcm...@google.com>
Gerrit-Comment-Date: Thu, 28 Oct 2021 20:25:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Bryan C. Mills (Gerrit)

unread,
Oct 28, 2021, 4:50:39 PM10/28/21
to Bryan C. Mills, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go Bot, Katie Hockman, golang-co...@googlegroups.com

Bryan C. Mills submitted this change.

View Change



1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Approvals: Katie Hockman: Looks good to me, approved; Trusted Bryan C. Mills: Trusted; Run TryBots Go Bot: TryBots succeeded
cmd/go: test with SIGTERM in test_fuzz_non_crash_signal

The test currently uses only SIGKILL (which cannot be trapped by the
worker process) and SIGILL (which is handled by the Go runtime, and
does pretty unambiguously indicate a crash). It is missing a third
(and perhaps more likely) case: a signal like SIGTERM that is handled
by the Go runtime and causes the test to terminate, but nonetheless
does not indicate a crash.

Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/359482
Trust: Bryan C. Mills <bcm...@google.com>
Trust: Katie Hockman <ka...@golang.org>
Run-TryBot: Bryan C. Mills <bcm...@google.com>
TryBot-Result: Go Bot <go...@golang.org>
Reviewed-by: Katie Hockman <ka...@golang.org>
---
M src/cmd/go/testdata/script/test_fuzz_non_crash_signal.txt
1 file changed, 42 insertions(+), 0 deletions(-)

To view, visit change 359482. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I0595a0917e977e8eb2c24ae8b706d734ce3b2f4f
Gerrit-Change-Number: 359482
Gerrit-PatchSet: 3
Gerrit-Owner: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Katie Hockman <ka...@golang.org>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages