JDK-8027421 : TEST_BUG: java/rmi/dgc/dgcAckFailure/DGCAckFailure.java fails in Xcomp mode
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.rmi
  • Affected Version: 7u51,8,9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-10-29
  • Updated: 2018-03-27
  • Resolved: 2018-03-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbd_minorFixed
Related Reports
Relates :  
Description
David Holmes added a comment - 2013-10-29 04:06
The failure mode of the test is:

java.rmi.NoSuchObjectException: no such object in table
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:161)
at DGCAckFailure_Stub.returnRemote(DGCAckFailure_Stub.java:56)
at DGCAckFailure.main(DGCAckFailure.java:80)

The code in question does this:

        Remote impl = new DGCAckFailure();
        ReferenceQueue refQueue = new ReferenceQueue();
        Reference weakRef = new WeakReference(impl, refQueue);
        ReturnRemote stub =
            (ReturnRemote) UnicastRemoteObject.exportObject(impl);
        System.err.println("remote object exported; stub = " + stub);

        try {
            Object wrappedStub = stub.returnRemote(); <= exception thrown here.

It appears that when everything is compiled with Xcomp, and the client compiler, the lifetime of the impl object is not what is normally encountered. We have seen similar issues before. Changing the test so that the local:

 Remote impl = new DGCAckFailure();

becomes a static field:

static Remote impl = new DGCAckFailure();

fixes the problem.

While not intuitive this is a test bug. When working with weakreferences etc you need to be extremely careful if your only strong reference is a local as this can be optimized away:

http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.6.1

"Optimizing transformations of a program can be designed that reduce the number of objects that are reachable to be less than those which would naively be considered reachable. For example, a Java compiler or code generator may choose to set a variable or parameter that will no longer be used to null to cause the storage for such an object to be potentially reclaimable sooner.

Another example of this occurs if the values in an object's fields are stored in registers. The program may then access the registers instead of the object, and never access the object again. This would imply that the object is garbage. Note that this sort of optimization is only allowed if references are on the stack, not stored in the heap. "
-----

Hence changing from a local stack variable to a static field (heap variable) fixes the problem.
Comments
Not seen in a long time
27-03-2018

----------System.err:(19/1224)---------- test socket factory set remote object exported; stub = DGCAckFailure_Stub[UnicastRef [liveRef: [endpoint:[127.0.0.1:33741](local),objID:[-18b104a0:140f3909f5d:-7fff, -1516001311554257582]]]] java.rmi.NoSuchObjectException: no such object in table at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162) at DGCAckFailure_Stub.returnRemote(DGCAckFailure_Stub.java:56) at DGCAckFailure.main(DGCAckFailure.java:80) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:491) at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94) at java.lang.Thread.run(Thread.java:724)
29-10-2013