staticanalysis / data-race-test

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

Go does not instrument a simple store to a struct member #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
src/pkg/net/http/transfer.go:613:
func (b *body) Close() error {
    if b.closed {
        return nil
    }
    defer func() {
        b.closed = true <<<=== HERE ===>>>
    }()
...
}

The closure compiles into:
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
  448089:       48 8b 1b                mov    (%rbx),%rbx
  44808c:       40 b5 01                mov    $0x1,%bpl
  44808f:       40 88 6b 31             mov    %bpl,0x31(%rbx)  <<<=== HERE ===>>>
  448093:       e8 c2 b9 fc ff          callq  413a5a <runtime.instrfuncexit>
  448098:       48 83 c4 08             add    $0x8,%rsp
  44809c:       c3                      retq   

b.closed = true is not instrumented.

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