That’s a very interesting read - thank you.
Are you sure that holds when using an atomic as a memory barrier - seems it would be very difficult for the compiler to know when it was safe to do that- it would need to understand the atomic framing. > On Sep 16, 2022, at 2:10 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Fri, Sep 16, 2022 at 7:43 AM robert engels <reng...@ix.netcom.com> wrote: > >> After some analysis and discussion, the sample I provided earlier has a data >> race by definition - although in many cases these are benign and do no >> affect the correctness of the program. > > There's no such thing [in Go and many other languages] as a benign > data race: > https://docs.google.com/document/d/1WAT22FtFdMt43i3O8YrnlQTNTzZ3IoJBtu3P2DNRytg/edit > >> E.g. the program may be “sampling” and so any valid value read is “ok”. > > Even when we forget that a data race can crash your program on certain > HW, the above quoted means you can replace the read with a PRNG, but > then, assuming your code is still correct, why bother with the read at > all? Because a racy read can produce not only some "old" value vs > "new" value with some probability. The racy read can produce any value > at all. Sure, at least some architectures have stronger guarantees and > they really produce "old" or "new" and nothing else, for certain sizes > and/or alignments of values. But not in the general case or for any > architecture that Go may support in the future. > > tl;dr: You must always fix a data race, there are no exceptions. > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAA40n-X5cK9eZpCRAi-yRO9X6s287KF6Dy%3Ds%2BL2%2BqM2CjW2cqQ%40mail.gmail.com. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/F7045C67-A8DE-4AAD-8195-56B0967803F2%40ix.netcom.com.