Bug in Truffle: parent is accessed racily

Christian Humer christian.humer at gmail.com
Fri Jan 20 17:41:52 UTC 2017


Hi Andrew,

Thanks for the report!
Interesting that this problem never occurred on x86 or sparc yet.

Will investigate a bit more, why it was not volatile in the first place.

Cheers,

Christian Humer


On 19.01.2017 18:44:34, "Andrew Haley" <aph at redhat.com> wrote:

>I've been seeing some odd failures in 
>InstrumentationMultiThreadingTest.
>I occasionally get NullPointerExceptions on Node.getRootNode().
>
>I think the real problem is in class Node, where Node.parent is 
>accessed
>racily by multiple threads.  parent really needs to be volatile:
>
>diff --git 
>a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java 
>b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
>index e153bc6..52a2c95 100644
>--- 
>a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
>+++ 
>b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java
>@@ -55,7 +55,7 @@ import com.oracle.truffle.api.utilities.JSONHelper;
>  public abstract class Node implements NodeInterface, Cloneable {
>
>      private final NodeClass nodeClass;
>-    @CompilationFinal private Node parent;
>+    @CompilationFinal private volatile Node parent;
>
>      /**
>       * Marks array fields that are children of this node.
>
>Andrew.



More information about the graal-dev mailing list