package main
import "runtime"
var a int
func calc() {
    for i := 0; i < 10; i++ {
        go func() {
            for {
                runtime.RaceDisable()
                a++
                runtime.RaceEnable()
            }
        }()

    }
}
func main() {
    calc()
}

go run -race a.go


在 2018年8月22日星期三 UTC+8下午10:34:35,Ian Lance Taylor写道:
>
> On Wed, Aug 22, 2018 at 3:25 AM,  <nea...@gmail.com <javascript:>> wrote: 
> > 
> > When I copy the sync.Pool's source code in a repo, and using 
> `//go:linkname` 
> > link those runtime functions manually. 
> > When I run `go test -race`, it reports `DATA RACE`. 
> > But the sync.Pool with the same test case does not report  `DATA RACE`. 
> > 
> > Does runtime.RaceDisable not work in non-std library ? 
>
> It should work.  I think you'll have to show us your code. 
>
> Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to