News for hackers. Stuff that matters.
Re:Updating the Go Memory Model by Diggsey on Monday July 12, 2021 @02:38PM (#27813540)
"Undefined behaviour" has a specific technical meaning. In Go, data races can result in UB. In Java, they can't.

Java may be non-deterministic, or exhibit unintended behaviour in response to a race condition. UB is strictly worse because it could do either of those things... or indeed anything else, segfaulting being the least of your concerns.

Re:Updating the Go Memory Model by ngrilly on Monday July 12, 2021 @03:26PM (#27813987)
This is the "technical meaning" of "undefined behaviour" according to Wikipedia:

> Undefined behavior (UB) is the result of executing a program whose behavior is prescribed to be unpredictable, in the language specification to which the computer code adheres.

Can we predict the behavior of a Java program with a data race?

Re:Updating the Go Memory Model by anderskaseorg on Monday July 12, 2021 @04:51PM (#27814960)
A section of Java code with a data race can’t break anything that the same section of code couldn’t have been rewritten to intentionally break without using a data race. For example: it might throw an exception, loop infinitely, or return valid values that the programmer didn’t expect; but it cannot corrupt the internal state of the JVM, violate type-safety, fiddle with private fields, or access data that isn’t reachable from its own variables. Data races cannot be used to violate a security barrier between mutually untrusting sections of Java code.
Re:Updating the Go Memory Model by ngrilly on Tuesday July 13, 2021 @11:35AM (#27822237)
You're right. That's a big advantage of the JVM. It's memory safe even in presence of data races.

That post from Russ Cox (again) explains quite well why Go is not memory safe in presence of data races, and what should be changed to fix this: https://research.swtch.com/gorace

Re:Updating the Go Memory Model by Diggsey on Tuesday July 13, 2021 @11:25AM (#27822113)
That's less a definition, and more a description of what UB looks like.

Here's a better definition: https://en.cppreference.com/w/cpp/language/ub

Re:Updating the Go Memory Model by UncleMeat on Monday July 12, 2021 @05:33PM (#27815397)
This depends on what "unpredictable" means. Do I know precisely what this java program will compute? No. But I do know some things that it won't do. Its behavior is not completely unbounded.
Re:Updating the Go Memory Model by Dylan16807 on Monday July 12, 2021 @10:48PM (#27817213)
That's a really bad standalone definition. It would apply to randomly generating numbers, or most attempts at allocating memory and then sorting by address.