<div dir="ltr"><div dir="auto">In fact, the assertion can be triggered by just this code:</div><div dir="auto"><font face="monospace"><br></font></div><font face="monospace">import static java.lang.foreign.ValueLayout.JAVA_LONG;<br><br></font><div><font face="monospace">import java.lang.foreign.Arena;<br>import java.lang.foreign.MemorySegment;<br></font><div dir="auto"><font face="monospace"><br>public class Repro {<br> static final int COUNT = 100000;<br> static final MemorySegment segment = Arena.global().allocate(JAVA_LONG, COUNT);<br><br> public static void main(String[] args) {<br> var i = 0;<br> var j = 0;<br> while (i < COUNT) {<br> segment.setAtIndex(JAVA_LONG, i++, 0);<br> segment.setAtIndex(JAVA_LONG, j++, 0);<br> }<br> }<br>}</font><br></div><div dir="auto"><font face="monospace"><br></font></div></div></div><div dir="auto"><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 31, 2024 at 13:26 Matthias Ernst <<a href="mailto:matthias@mernst.org" target="_blank">matthias@mernst.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, I've come across an assertion tripping in JDK debug builds (24, latest, not 23) in combination with new foreign memory apis. Product builds seem to be functioning ok:<div><div style="box-sizing:border-box;display:flex;color:rgb(31,35,40);font-family:-apple-system,"system-ui","Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";font-size:16px;overflow:auto"><pre style="box-sizing:border-box;font-size:13.6px;margin-top:0px;margin-bottom:0px;overflow:auto;line-height:1.45;border-radius:6px"><code style="box-sizing:border-box;padding:0px;margin:0px;background:transparent;border-radius:6px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit"># Internal Error (src/hotspot/share/opto/loopnode.cpp:3196), pid=27, tid=44
# Error: assert(!loop->_body.contains(in)) failed
</code></pre><div style="box-sizing:border-box"><span aria-label="Copy" value="% javac Repro.java
% java -Xbatch -XX:-TieredCompilation Repro
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (src/hotspot/share/opto/loopnode.cpp:3196), pid=27, tid=44
# Error: assert(!loop->_body.contains(in)) failed" role="button" style="box-sizing:border-box;font-size:14px;line-height:20px;vertical-align:middle;border:0px;border-radius:6px;background-color:transparent;display:flex;padding:0px"></span></div></div><br></div><div>I've been able to narrow it down somewhat, repro code/data as well as crash logs can be found here: <a href="https://github.com/mernst-github/repro/tree/main/loopnode-assertion" target="_blank">https://github.com/mernst-github/repro/tree/main/loopnode-assertion</a> (this was originally a standard `quicksort` on top of a MemorySegment).</div><div><br></div><div>I have not been able to discover anything more systematic. Small changes to the input data, or using a heap array instead of a MemorySegment make the issue go away.</div><div><br></div><div>Cheers</div><div>Matthias</div><div>(PS: lmk if this is not an opportune place to report such an issue)</div><div><br></div></div>
</blockquote></div></div>