Good explanation, Marvin. This is precisely why we have the race detector.
If all races produced a panic, then it would not be needed. Some races
behave "correctly" for a long time, and only on rare occasion result in
silent data corruption that can be almost impossible to debug. Other races
mi
* Yuan Ting [200301 23:50]:
> I write a simple program likes below and it triggers a data race alarm with
> -race flag. But no matter how I run, this program will not panic. I know it
> is legal to receive messages from nil channels, but I don't quite
> understand why this program does not pani
How about the main go compiler? Will the code generated by the main go
compiler panic as you analyze?
On Monday, March 2, 2020 at 2:11:47 PM UTC+8, Jan Mercl wrote:
>
> On Mon, Mar 2, 2020 at 6:56 AM burak serdar > wrote:
>
> > At this point, channel receive is still holding a reference to the
I'm not sure if the channel receive is atomic. I thought it would get a
null pointer dereference error in chanrecv at runtime.
On Monday, March 2, 2020 at 1:37:01 PM UTC+8, burak serdar wrote:
>
> On Sun, Mar 1, 2020 at 9:49 PM Yuan Ting >
> wrote:
> >
> > I write a simple program likes below
On Mon, Mar 2, 2020 at 6:56 AM burak serdar wrote:
> At this point, channel receive is still holding a reference to the
> channel (right?), so GC cannot free it.
Depends very much on what code the compiler for channel receive
generates and on the code in the runtime that implements the channel
r
On Sun, Mar 1, 2020 at 10:49 PM Jan Mercl <0xj...@gmail.com> wrote:
>
> On Mon, Mar 2, 2020 at 6:36 AM burak serdar wrote:
>
> > Why should it panic? The first goroutine simply sets the channel to
> > nil. The second goroutine will either block reading from a non-nil
> > channel, or block reading
On Mon, Mar 2, 2020 at 6:36 AM burak serdar wrote:
> Why should it panic? The first goroutine simply sets the channel to
> nil. The second goroutine will either block reading from a non-nil
> channel, or block reading from a nil channel. There is no code in this
> program that would panic.
It ca
On Sun, Mar 1, 2020 at 9:49 PM Yuan Ting wrote:
>
> I write a simple program likes below and it triggers a data race alarm with
> -race flag. But no matter how I run, this program will not panic. I know it
> is legal to receive messages from nil channels, but I don't quite understand
> why this
I write a simple program likes below and it triggers a data race alarm with
-race flag. But no matter how I run, this program will not panic. I know it
is legal to receive messages from nil channels, but I don't quite
understand why this program does not panic in the presence of data races.
ch