News for hackers. Stuff that matters.
Re:Updating the Go Memory Model by shp0ngle on Tuesday July 13, 2021 @01:26AM (#27817846)
This is very different and it seems a lot of people misunderstand this.

Undefined behavior is not "data structure being corrupted". When data structures are corrupted, program still functions as written.

Undefined behavior is "things fly off the ceiling", no logic applies and programs start behaving essentially randomly because of the optimizations.

Undefined behavior is not broken data. That is still a well defined behavior.

Re:Updating the Go Memory Model by labawi on Thursday July 15, 2021 @02:23PM (#27848202)
Behavior of a program after data (as in value) races can be defined and constrained.

If you have wild pointer writes (aka arbitrary memory corruption) and almost any non-trivial control flow, the results are pretty much undefined. As in, it is pretty much impossible to specify or reason about what a program will do.

The article:

> ... such races can in turn lead to arbitrary memory corruption.

Tearing writes themselves are not undefined behavior, but use them wrong and you're off into undefined territory, with no way back.

> Undefined behavior is .. because of the optimizations.

Optimizations are popular, but it doesn't matter why the behavior is undefined.