Skip to content

runtime: SetCPUProfileRate(0) crashes if profiler is already off #7063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
emidoots opened this issue Jan 4, 2014 · 2 comments
Closed

runtime: SetCPUProfileRate(0) crashes if profiler is already off #7063

emidoots opened this issue Jan 4, 2014 · 2 comments

Comments

@emidoots
Copy link

emidoots commented Jan 4, 2014

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Call runtime.SetCPUProfileRate(0) *with* the profiler already off (I.e. no previous
calls to runtime.SetCPUProfileRate).
2. A crash due to nil pointer dereference occurs.
3. Example (also happens on playground): http://play.golang.org/p/whHf24PCI5

What is the expected output?
The program should run without crashing.

What do you see instead?
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4052ca]

goroutine 1 [running]:
runtime.panic(0x4ab880, 0x5a1d48)
    /home/stephen/go/src/pkg/runtime/panic.c:264 +0xb6
main.main()
    /home/stephen/Desktop/godev/src/code.google.com/p/goprof/cmd/goprof/goprof.go:24 +0x2e


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
I tested the same program and it crashed on the playground as well as my personal
linux/amd64 and windows/amd64 intel i7 machine.

Which version are you using?  (run 'go version')
Tip in both test cases - go version devel +36d5461843ce

Please provide any additional information below.

Maybe a test should be added for this too; since I think runtime/pprof is the only
client who uses this function in the standard library? I'm not sure.
@ceh
Copy link
Contributor

ceh commented Jan 5, 2014

Comment 1:

https://golang.org/cl/47950043

@ianlancetaylor
Copy link
Contributor

Comment 2:

This issue was closed by revision aeeda70.

Status changed to Fixed.

@emidoots emidoots added the fixed label Jan 6, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants