[go] runtime: disable CPU profiling before removig the SIGPROF handler

34 views
Skip to first unread message

Ian Lance Taylor (Gerrit)

unread,
Jun 18, 2021, 12:56:54 PM6/18/21
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Bryan C. Mills, Tobias Klauser, Go Bot, golang-co...@googlegroups.com

Ian Lance Taylor submitted this change.

View Change

Approvals: Bryan C. Mills: Looks good to me, approved Ian Lance Taylor: Trusted
runtime: disable CPU profiling before removing the SIGPROF handler

Otherwise, in c-archive or c-shared mode, there is the chance of
getting a SIGPROF just after the signal handler is removed but before
profiling is disabled, in which case the program will die.

Fixes #46498

Change-Id: I5492beef45fec9fb9a7f58724356d6aedaf799ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/329290
Trust: Ian Lance Taylor <ia...@golang.org>
Reviewed-by: Bryan C. Mills <bcm...@google.com>
---
M src/runtime/signal_unix.go
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
index f2e5269..03e2a40 100644
--- a/src/runtime/signal_unix.go
+++ b/src/runtime/signal_unix.go
@@ -280,6 +280,8 @@
it.it_value = it.it_interval
setitimer(_ITIMER_PROF, &it, nil)
} else {
+ setitimer(_ITIMER_PROF, &itimerval{}, nil)
+
// If the Go signal handler should be disabled by default,
// switch back to the signal handler that was installed
// when we enabled profiling. We don't try to handle the case
@@ -303,8 +305,6 @@
setsig(_SIGPROF, h)
}
}
-
- setitimer(_ITIMER_PROF, &itimerval{}, nil)
}
}


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

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

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I5492beef45fec9fb9a7f58724356d6aedaf799ac
Gerrit-Change-Number: 329290
Gerrit-PatchSet: 3
Gerrit-Owner: Ian Lance Taylor <ia...@golang.org>
Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
Gerrit-Reviewer: Go Bot <go...@golang.org>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
Gerrit-CC: Tobias Klauser <tobias....@gmail.com>
Gerrit-MessageType: merged
Reply all
Reply to author
Forward
0 new messages