Re: [go-nuts] Understanding go routine heap

2016-08-20 Thread Marvin Renich
* Konstantin Shaposhnikov [160820 06:34]: > The code might be race free for the current Go implementation but I don't > think this behaviour is documented. > > https://golang.org/ref/mem doesn't mention sync.WaitGroup at all. So > wg.Done() doesn't necessarily happen

Re: [go-nuts] Understanding go routine heap

2016-08-20 Thread Konstantin Shaposhnikov
The code might be race free for the current Go implementation but I don't think this behaviour is documented. https://golang.org/ref/mem doesn't mention sync.WaitGroup at all. So wg.Done() doesn't necessarily happen before wg.Wait() returns and the effect of writing to "result" could be not

Re: [go-nuts] Understanding go routine heap

2016-08-20 Thread Dave Cheney
I haven't run the code under the race detector (hint, do this and you'll have the official answer) but I don't believe wg.Wait creates a happens before event that ensures the assignment to result will be visible to other goroutine. -- You received this message because you are subscribed to

Re: [go-nuts] Understanding go routine heap

2016-08-20 Thread Jan Mercl
On Sat, Aug 20, 2016 at 8:29 AM Yulrizka wrote: > He argues that this is heap race condition. I don't know what is a heap race condition but the code is race free. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

[go-nuts] Understanding go routine heap

2016-08-20 Thread Yulrizka
Dear gophers I have discussion with my colleague about this code func process() *foo { var result *foo var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() result = {1} }() wg.Wait() return result } He argues that this is heap race