RFR: 8181085: Race condition in method resolution may produce spurious NullPointerException

Andrew Dinn adinn at redhat.com
Thu May 25 13:12:53 UTC 2017


The following webrev fixes a race condition that is present in jdk10 and
also jdk9 and jdk8. It is caused by a misplaced volatile keyword that
faild to ensure correct ordering of writes by the compiler. Reviews welcome.

  http://cr.openjdk.java.net/~adinn/8181085/webrev.00/

Backporting:
This same fix is required in jdk9 and jdk8.

Testing:
The reproducer posted with the original issue manifests the NPE reliably
on jdk8. It does not manifest on jdk9/10 but that is only thanks to
changes introduced into the resolution process in jdk9 which change the
timing of execution. However, without this fix the out-of-order write
problem is still present in jdk9/10, as can be seen by eyeballing the
compiled code for ConstantPoolCacheEntry::set_direct_or_vtable_call.

The patch has been validated on jdk8 by running the reproducer. It stops
any resulting NPEs.

The code for ConstantPoolCacheEntry::set_direct_or_vtable_call on
jdk8-10 has been eyeballed to ensure that post-patch the assignments now
occur in the correct order.

regards,


Andrew Dinn
-----------
Senior Principal Software Engineer
Red Hat UK Ltd
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham, Michael ("Mike") O'Neill, Eric Shander


More information about the jdk10-dev mailing list