4 ms·
Is Java really memory safe in the face of races? The case I'm thinking about is this: Shared state: ArrayList A with intial buffer B and length L Thread 1:
by uluyol 5y ago
Is Java really memory safe in the face of races? The case I'm thinking about is this:
Shared state:
ArrayList A with intial buffer B and length L
Thread 1:
Grows A and replaces B with buffer C, length with M
Thread 2:
(Earlier loaded B into a register)
Code says write to A[M-1]. JVM checks M-1 against M but uses B as it was already stored in a register. Now you have a buffer overflow.
Except, people on this thread seem to think this is impossible. How does Java prevent this?