staticanalysis / data-race-test

Automatically exported from code.google.com/p/data-race-test
0 stars 0 forks source link

Go: false positive on stack #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I see the following report:
WARNING: Possible data race during write of size 1 at 0x7fc7bb7a5e78: {{{
   T142 (L{}):
    #0  0x448084: net/http._func_006 src/pkg/net/http/transfer.go:613
    #1  0x43752a: net/http..Close src/pkg/net/http/transfer.go:610
    #2  0x431420: net/http..finishRequest src/pkg/net/http/server.go:533
    #3  0x431b82: net/http..serve src/pkg/net/http/server.go:658
    #4  0x410eff: runtime.goexit src/pkg/runtime/proc.c:266
  Concurrent write(s) happened at (OR AFTER) these points:
   T126 (L{}):
    #0  0x448084: net/http._func_006 src/pkg/net/http/transfer.go:613
    #1  0x43752a: net/http..Close src/pkg/net/http/transfer.go:610
    #2  0x431420: net/http..finishRequest src/pkg/net/http/server.go:533
    #3  0x431b82: net/http..serve src/pkg/net/http/server.go:658
    #4  0x410eff: runtime.goexit src/pkg/runtime/proc.c:266
}}}

It refers to a *stack* memory, something that should never happen in Go.

func (b *body) Close() error {
    if b.closed {
        return nil
    }
    defer func() {
        <<<=== HERE ===>>>
        b.closed = true
    }()
...
}

000000000044805a <net/http._func_006>:
  44805a:       64 48 8b 0c 25 f0 ff    mov    %fs:0xfffffffffffffff0,%rcx
  448061:       ff ff 
  448063:       48 3b 21                cmp    (%rcx),%rsp
  448066:       77 05                   ja     44806d <net/http._func_006+0x13>
  448068:       e8 d9 c2 fb ff          callq  404346 <runtime.morestack8>
  44806d:       48 83 ec 08             sub    $0x8,%rsp
  448071:       e8 6e b9 fc ff          callq  4139e4 <runtime.instrfuncenter>
  448076:       48 8b 5c 24 10          mov    0x10(%rsp),%rbx
  44807b:       48 89 1c 24             mov    %rbx,(%rsp)
  44807f:       e8 2b ba fc ff          callq  413aaf <runtime.instrwrite>
  448084:       48 8b 5c 24 10          mov    0x10(%rsp),%rbx <<<=== HERE ===>>>
  448089:       48 8b 1b                mov    (%rbx),%rbx
  44808c:       40 b5 01                mov    $0x1,%bpl
  44808f:       40 88 6b 31             mov    %bpl,0x31(%rbx)
  448093:       e8 c2 b9 fc ff          callq  413a5a <runtime.instrfuncexit>
  448098:       48 83 c4 08             add    $0x8,%rsp
  44809c:       c3                      retq   

Original issue reported on code.google.com by dvyu...@google.com on 16 Jan 2012 at 8:44

GoogleCodeExporter commented 9 years ago

Original comment by mpime...@google.com on 30 Mar 2012 at 4:01