1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:20:22 -07:00

runtime: Fix panic when trying to stop CPU profiling with profiler turned off

Fixes #7063.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/47950043
This commit is contained in:
Emil Hessman 2014-01-06 09:53:55 -08:00 committed by Ian Lance Taylor
parent 79653e4121
commit aeeda707ff
2 changed files with 6 additions and 1 deletions

View File

@ -168,7 +168,7 @@ runtime·SetCPUProfileRate(intgo hz)
runtime·noteclear(&prof->wait); runtime·noteclear(&prof->wait);
runtime·setcpuprofilerate(tick, hz); runtime·setcpuprofilerate(tick, hz);
} else if(prof->on) { } else if(prof != nil && prof->on) {
runtime·setcpuprofilerate(nil, 0); runtime·setcpuprofilerate(nil, 0);
prof->on = false; prof->on = false;

View File

@ -126,3 +126,8 @@ func TestRuntimeGogoBytes(t *testing.T) {
t.Fatalf("go tool nm did not report size for runtime.gogo") t.Fatalf("go tool nm did not report size for runtime.gogo")
} }
// golang.org/issue/7063
func TestStopCPUProfilingWithProfilerOff(t *testing.T) {
SetCPUProfileRate(0)
}