3 ms·
I think Go was wise to begin by telling programmers if they care about these details they're being too clever and will regret it. Detailed memory models so far
by tialaramex 5y ago
I think Go was wise to begin by telling programmers if they care about these details they're being too clever and will regret it. Detailed memory models so far over-promise and under-deliver and the main justification for them is trying to squeeze out that last few percent of performance which is not what Go is for.
However:
> The first, exemplified by C and C++, is that programs with data races are invalid: a compiler may break them in arbitrarily surprising ways.
The problem isn't just the compiler. If you write code with a data race the CPU might break your program in arbitrarily surprising ways too. Go programs don't rely on your C++ compiler, but they do run on your CPU and not a virtual machine.
Is Go really going to be able to deliver defined semantics here in the face of that?
> The second, exemplified by Java and JavaScript, is that programs with data races have defined semantics, limiting the possible impact of a race and making programs more reliable and easier to debug.
This was definitely the intention. But, do the results match that intention? It seems like in fact Java programmers are still confused by what happened when there's a data race, even though the semantics of a data race in Java are more limited, they're beyond the conception of the programmer anyway.
Do you go less insane if you see only two Great Old Ones than if you were to see a host of them? Or does the distinction not make a difference?
Later this document proposes the new Go model should say:
> such races can in turn lead to arbitrary memory corruption.
That's a much worse outcome than in Java. So I'd be astonished if Go programmers are able to meaningfully debug a program in which a data race has smashed unrelated data structures. In fact, I'm dubious as to what difference is even left between "arbitrary memory corruption" and C++ undefined behaviour. Experts will sometimes draw on their experience to guess correctly what went wrong. Specialist instrumentation might help find your root cause. But these are the same in C++
- yc12340 5y ago> Java programmers are still confused by what happened when there's a data race IMO, the most important thing is that JVM runtime isn't being confused into executing attacker's code. Most programmers are unable to precisely predict behaviour of their programs anyway, — they get accustomed to being confused.
- astrange 5y agoIf this is the definition then JavaScript doesn't meet it very well, given how often there are browser exploits.
- voidnullnil 5y agoThat's not how this works. This discussion is about preventing a something like a server from being exploited. How many stack smashes have you seen against a server written in a memory-safe language?