<div dir="ltr"><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">Hi all,</span><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">While we were testing an internal project at Hazelcast using 1.8.0_60-ea-b18 & 1.9.0-ea-b67, we encountered a previously reported sun.misc.Unsafe issue. </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><a href="https://bugs.openjdk.java.net/browse/JDK-8076445" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8076445</a><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><a href="http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-April/017685.html" target="_blank">http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-April/017685.html</a><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">Issue status says it's resolved with resolution "<span style="color:rgb(0,0,0);font-family:sans-serif;font-size:13px;line-height:17.0000991821289px">Cannot Reproduce</span>".  But unfortunately it's still reproducible using "1.8.0_60-ea-b18" and "1.9.0-ea-b67". </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">Test is very simple:</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">```</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><div>public static void main(String[] args) throws Exception {</div><div>        Unsafe unsafe = findUnsafe();</div><div>        // 10000 pass</div><div>        // 100000 jvm crash</div><div>        // 1000000 fail</div><div>        int count = 100000;</div><div>        long size = count * 8L;</div><div>        long baseAddress = unsafe.allocateMemory(size);</div><div><br></div><div>        try {</div><div>            for (int i = 0; i < count; i++) {</div><div>                long address = baseAddress + (i * 8L);</div><div><br></div><div>                long expected = i;</div><div>                unsafe.putLong(address, expected);</div><div><br></div><div>                long actual = unsafe.getLong(address);</div><div><br></div><div>                if (expected != actual) {</div><div>                    throw new AssertionError("Expected: " + expected + ", Actual: " + actual);</div><div>                }</div><div>            }</div><div>        } finally {</div><div>            unsafe.freeMemory(baseAddress);</div><div>        }</div><div>    }</div></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">```</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">It's not failing up to version 1.8.0.31, by starting 1.8.0.40 test is failing constantly. </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- With iteration count 10000, test is passing. </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- With iteration count 100000, jvm is crashing with SIGSEGV.</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- With iteration count 1000000, test is failing with AssertionError. </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">When one of compilation (-Xint) or inlining (-XX:-Inline) or on-stack-replacement (-XX:-UseOnStackReplacement) is disabled, test is not failing at all. </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">Also, when address calculation in the loop is converted to </span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">long address = baseAddress + (i * 8) </span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">test passes. Only difference is, next address is calculated using integer 8 instead of long 8. </span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">```</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">for (int i = 0; i < count; i++) {</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    long address = baseAddress + (i * 8); // <--- here, integer 8 instead of long 8</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    long expected = i;</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    unsafe.putLong(address, expected);</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    long actual = unsafe.getLong(address);</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    if (expected != actual) {</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">        throw new AssertionError("Expected: " + expected + ", Actual: " + actual);</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">    }</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">}</span></div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">```</span></div></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">I tested on versions: </div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">- 1.8.0.40</span><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- 1.8.0.45<br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- 1.8.0_60-ea-b18<br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">- 1.9.0-ea-b67<br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">Previous issue comment (<a href="https://bugs.openjdk.java.net/browse/JDK-8076445?focusedCommentId=13633043#comment-13633043" target="_blank">https://bugs.openjdk.java.net/browse/JDK-8076445?focusedCommentId=13633043#comment-13633043</a>) says "<span style="color:rgb(0,0,0);font-family:sans-serif;font-size:13px;line-height:17.0000991821289px;background-color:rgb(224,240,255)">Cannot reproduce based on the latest version".</span> I hope that latest version is not mentioning to '1.8.0_60-ea-b18' or '1.9.0-ea-b67'. Because both are failing.</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"> </div><div><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">PS: Cross posted this on '</span><span style="font-size:13.1999998092651px;line-height:19.7999992370605px;color:rgb(153,153,153);white-space:nowrap">hotspot-compiler-dev</span><span style="font-size:13.1999998092651px;line-height:19.7999992370605px">' group but still haven't got a response yet. <a href="http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-June/018191.html">http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2015-June/018191.html</a></span></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px"><br></div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">Thanks,</div><div style="font-size:13.1999998092651px;line-height:19.7999992370605px">Mehmet Dogan</div></div><div dir="ltr">-- <br></div><div dir="ltr"><p dir="ltr">@mmdogan</p>
</div>