NTA proxy object aliasing in concurrent mode

Issue #290 resolved
Jesper Öqvist created an issue

Proxy objects that are created to enable inherited attribute evaluation for parameterized NTAs can become aliased between separate nodes after cloning a node. This can cause incorrect inherited attribute values for NTAs.

The cause of this error is that the AtomicReference object containing the proxy reference is not reset when creating a fresh node.

A test case demonstrating this error:

aspect Test {
  syn nta B A.b(String id) = new B(id);

  inh String B.outer();
  eq A.b().outer() = getID();
}
// Test that NTA proxy objects are not aliased between fresh nodes.
// .grammar: { A ::= <ID>; B ::= <ID>; }
// .options: concurrent=true
import static runtime.Test.*;
import java.util.ArrayList;

public class Test {
  public static void main(String args[]) {
    A a = new A("oh hi");

    // Proxy object is not aliased after copying (1).
    A a2 = a.treeCopyNoTransform();
    a2.setID("bye");

    // Proxy object is not aliased after copying (2).
    A a3 = a.treeCopyNoTransform();
    a3.setID("x");

    testEqual("oh hi", a.b("one").outer());
    testEqual("bye", a2.b("one").outer());
    testEqual("x", a3.b("one").outer());

    testEqual("x", a3.b("two").outer());
    testEqual("bye", a2.b("two").outer());
    testEqual("oh hi", a.b("two").outer());

    // Proxy object is reset after makeFreshNode.
    a.makeFreshNode();
    a.setID("nope");
    testEqual("nope", a.b("one").outer());
    testEqual("nope", a.b("three").outer());
  }
}

Comments (1)

  1. Jesper Öqvist reporter

    Fix NTA proxy object aliasing in concurrent mode

    This ensures that NTA proxy objects are fully reset when creating a fresh node.

    Also fixed a compile error caused by using the wrong name for a proxy object (_list instead of _proxy).

    fixes #290 (bitbucket)

    → <<cset 53c693bd2980>>

  2. Log in to comment