RFR: 8256732: Zero: broken +ZeroTLAB exposes badly initialized memory [v3]

Aleksey Shipilev shade at openjdk.java.net
Mon Nov 23 19:21:10 UTC 2020


> Looks like memory is badly initialized when `-XX:+ZeroTLAB` is specified.
> 
> Manifests like this:
> 
> $ CONF=linux-x86_64-zero-fastdebug make exploded-test TEST=compiler/memoryinitialization/ZeroTLABTest.java
> 
> command: main -Xcomp -XX:+UseTLAB -XX:+ZeroTLAB compiler.memoryinitialization.ZeroTLABTest
> reason: User specified action: run main/othervm -Xcomp -XX:+UseTLAB -XX:+ZeroTLAB compiler.memoryinitialization.ZeroTLABTest
> Mode: othervm [/othervm specified]
> elapsed time (seconds): 0.098
> configuration:
> STDOUT:
> Error occurred during initialization of VM
> java.lang.NullPointerException
> at java.lang.System.getProperty(java.base/System.java:836)
> 
> The cause is simple: Zero calls `ThreadLocalAllocBuffer::allocate`:
> 
> if (UseTLAB) {
>   result = (oop) THREAD->tlab().allocate(obj_size);
> }
> 
> ...which actually says:
> 
> // Allocate size HeapWords. The memory is NOT initialized to zero.
> inline HeapWord* allocate(size_t size);
> So if we do `+ZeroTLAB`, then Zero skips zeroing the object body, and gets bad uninitialized memory for non-zeroed TLAB. Since `ZeroTLAB` is "false" by default, I believe just doing the object body initialization unconditionally is fine.

Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits:

 - Merge branch 'master' into JDK-8256732-zero-zerotlab-broken
 - Maintain the body/header initialization order
 - 8256732: Zero: broken +ZeroTLAB exposes badly initialized memory

-------------

Changes: https://git.openjdk.java.net/jdk/pull/1343/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1343&range=02
  Stats: 11 lines in 1 file changed: 3 ins; 1 del; 7 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1343.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1343/head:pull/1343

PR: https://git.openjdk.java.net/jdk/pull/1343


More information about the hotspot-runtime-dev mailing list