I think this boils down to: Your code is _missing_ the relevant CAS
from the original code.

V.

On Tuesday, 30 April 2019 05:18:39 UTC+2, jacki...@gmail.com wrote:
>
> On line 85 in 
> https://github.com/golang/go/blob/release-branch.go1.12/src/sync/mutex.go , 
> the code " old := m.state " is weired because m.state is read and write 
> by different goroutine.
> Why it can't be detected by race condition detector.
>
>
> I write a function Test with race condition problem. 
> If put it in src/sync/mutex.go, it can't be detected.
> If put it in other package like os.go, it can be detected.
> That's weired, anyone has some idea ?
>
>
> package main
> import(
>     "sync"
>     "os")
> func main(){
>     sync.Test()        // race condition will not detect
>     os.Test()          // race condition will detect}
>
>
>
> func Test(){
>     a := int32(1)
>
>         if race.Enabled {
>         race.Acquire(unsafe.Pointer(&a))
>     }
>
>         go func(){
>                 atomic.CompareAndSwapInt32(&a, 1, 4)
>         }()
>         _ = a}
>
>

-- 
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