From af0802295b9f3b97cdad2acf0692fbb5d056a1ed Mon Sep 17 00:00:00 2001 From: Leonard Wang Date: Tue, 21 Dec 2021 00:25:33 +0800 Subject: [PATCH] runtime/pprof: Remove SIGPROF if the last event is stopped. --- src/runtime/proc.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index f7a57d75cc8c9..f175ab65974a7 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -4642,7 +4642,8 @@ func setcpuprofileconfig(eventId cpuEvent, profConfig *cpuProfileConfig) { // Restore SIGPROF only if all events are stopped eventsRunning := false for i := _CPUPROF_FIRST_EVENT; i < _CPUPROF_EVENTS_MAX; i++ { - if prof[i].config != nil { + // If the current event is the last event to be stopped, we should also restore SIGPROF too. + if prof[i].config != nil && i != eventId { eventsRunning = true break }