]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: Fix panic when trying to stop CPU profiling with profiler turned off
authorEmil Hessman <c.emil.hessman@gmail.com>
Mon, 6 Jan 2014 17:53:55 +0000 (09:53 -0800)
committerIan Lance Taylor <iant@golang.org>
Mon, 6 Jan 2014 17:53:55 +0000 (09:53 -0800)
Fixes #7063.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/47950043

src/pkg/runtime/cpuprof.c
src/pkg/runtime/runtime_test.go

index 1c34b9e6f61417113e2db4d39c7c2013d42a748c..040ffcd8c72d5a4a6fcaabd291b093129c7b769d 100644 (file)
@@ -168,7 +168,7 @@ runtime·SetCPUProfileRate(intgo hz)
                runtime·noteclear(&prof->wait);
 
                runtime·setcpuprofilerate(tick, hz);
-       } else if(prof->on) {
+       } else if(prof != nil && prof->on) {
                runtime·setcpuprofilerate(nil, 0);
                prof->on = false;
 
index f6b48ba3a6d4d74c766790e8ef7a7fcd37e6dfb3..c673275620b609c84985304b265c0dc5c9d4e23e 100644 (file)
@@ -126,3 +126,8 @@ func TestRuntimeGogoBytes(t *testing.T) {
 
        t.Fatalf("go tool nm did not report size for runtime.gogo")
 }
+
+// golang.org/issue/7063
+func TestStopCPUProfilingWithProfilerOff(t *testing.T) {
+       SetCPUProfileRate(0)
+}