]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/pprof: fix data race
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 12 Aug 2014 21:02:01 +0000 (01:02 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 12 Aug 2014 21:02:01 +0000 (01:02 +0400)
It's unclear why we do this broken double-checked locking.
The mutex is not held for the whole duration of CPU profiling.
Fixes #8365.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/116290043

src/pkg/runtime/pprof/pprof.go

index 26aa0b8be5cf0fc5f12fcbc082b0d42d5daa2133..236de54f384cabc24effed0da6c188ed1756a0e9 100644 (file)
@@ -574,12 +574,6 @@ func StartCPUProfile(w io.Writer) error {
        // each client to specify the frequency, we hard code it.
        const hz = 100
 
-       // Avoid queueing behind StopCPUProfile.
-       // Could use TryLock instead if we had it.
-       if cpu.profiling {
-               return fmt.Errorf("cpu profiling already in use")
-       }
-
        cpu.Lock()
        defer cpu.Unlock()
        if cpu.done == nil {