<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Maurizio, the code I was able to get out of the email is below:</div><div><br></div><div dir="ltr"><div style="color:rgb(169,178,195);background-color:rgb(33,37,43);font-family:"Jetbrains Mono",Consolas,"Courier New",monospace,Consolas,"Courier New",monospace;font-size:13px;line-height:20px;white-space:pre"><div><span style="color:rgb(97,175,239)">public</span> <span style="color:rgb(97,175,239)">class</span> <span style="color:rgb(229,192,123)">StdLibTest</span> {</div><br><div> <span style="color:rgb(97,175,239)">private</span> <span style="color:rgb(97,175,239)">static</span> <span style="color:rgb(229,192,123)">MethodHandle</span> <span style="color:rgb(198,204,215)">strlen</span>; <span style="color:rgb(95,102,114);font-style:italic">// C's strlen() function</span></div><div> <span style="color:rgb(97,175,239)">private</span> <span style="color:rgb(97,175,239)">static</span> <span style="color:rgb(229,192,123)">MethodHandle</span> <span style="color:rgb(198,204,215)">strcat</span>; <span style="color:rgb(95,102,114);font-style:italic">// C's strcat() function</span></div><br><div> @<span style="color:rgb(229,192,123)">BeforeAll</span></div><div> <span style="color:rgb(97,175,239)">public</span> <span style="color:rgb(97,175,239)">static</span> <span style="color:rgb(97,175,239)">void</span> <span style="color:rgb(181,126,220)">locateFunctions</span>() {</div><div> <span style="color:rgb(229,192,123)">Linker</span> <span style="color:rgb(198,204,215)">linker</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">Linker</span>.<span style="color:rgb(181,126,220)">nativeLinker</span>();</div><div> <span style="color:rgb(198,204,215)">strlen</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">linker</span>.<span style="color:rgb(181,126,220)">downcallHandle</span>(<span style="color:rgb(198,204,215)">linker</span>.<span style="color:rgb(181,126,220)">defaultLookup</span>().<span style="color:rgb(181,126,220)">find</span>("<span style="color:rgb(152,195,121)">strlen</span>").<span style="color:rgb(181,126,220)">get</span>(),</div><div> <span style="color:rgb(198,204,215)">FunctionDescriptor</span>.<span style="color:rgb(181,126,220)">of</span>(JAVA_LONG, ADDRESS));</div><div> <span style="color:rgb(198,204,215)">strcat</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">linker</span>.<span style="color:rgb(181,126,220)">downcallHandle</span>(<span style="color:rgb(198,204,215)">linker</span>.<span style="color:rgb(181,126,220)">defaultLookup</span>().<span style="color:rgb(181,126,220)">find</span>("<span style="color:rgb(152,195,121)">strcat</span>").<span style="color:rgb(181,126,220)">get</span>(),</div><div> <span style="color:rgb(198,204,215)">FunctionDescriptor</span>.<span style="color:rgb(181,126,220)">of</span>(ADDRESS, ADDRESS, ADDRESS));</div><div> }</div><br><br><div> @<span style="color:rgb(229,192,123)">Test</span></div><div> <span style="color:rgb(97,175,239)">public</span> <span style="color:rgb(97,175,239)">void</span> <span style="color:rgb(181,126,220)">strlen</span>() <span style="color:rgb(97,175,239)">throws</span> <span style="color:rgb(229,192,123)">Throwable</span> {</div><div> <span style="color:rgb(224,108,117)">try</span> (<span style="color:rgb(229,192,123)">Arena</span> <span style="color:rgb(198,204,215)">arena</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">Arena</span>.<span style="color:rgb(181,126,220)">openConfined</span>()) {</div><div> <span style="color:rgb(229,192,123)">MemorySegment</span> <span style="color:rgb(198,204,215)">segment</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">arena</span>.<span style="color:rgb(181,126,220)">allocateUtf8String</span>("<span style="color:rgb(152,195,121)">Hello</span>");</div><div> <span style="color:rgb(97,175,239)">int</span> <span style="color:rgb(198,204,215)">length</span> <span style="color:rgb(224,108,117)">=</span> (<span style="color:rgb(97,175,239)">int</span>) (<span style="color:rgb(97,175,239)">long</span>) <span style="color:rgb(198,204,215)">strlen</span>.<span style="color:rgb(181,126,220)">invoke</span>(<span style="color:rgb(198,204,215)">segment</span>);</div><div> <span style="color:rgb(198,204,215)">Assertions</span>.<span style="color:rgb(181,126,220)">assertSame</span>(<span style="color:rgb(86,182,194)">5</span>, <span style="color:rgb(198,204,215)">length</span>);</div><div> }</div><div> }</div><br><div> </div><div> @<span style="color:rgb(229,192,123)">Test</span></div><div> <span style="color:rgb(97,175,239)">public</span> <span style="color:rgb(97,175,239)">void</span> <span style="color:rgb(181,126,220)">foo</span>() <span style="color:rgb(97,175,239)">throws</span> <span style="color:rgb(229,192,123)">Throwable</span> {</div><div> <span style="color:rgb(229,192,123)">String</span> <span style="color:rgb(198,204,215)">result</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(181,126,220)">strcat</span>("<span style="color:rgb(152,195,121)">hello</span>", "<span style="color:rgb(152,195,121)">world</span>");</div><div> }</div><div> </div><div><span style="color:rgb(95,102,114);font-style:italic"> /**</span></div><div><span style="color:rgb(95,102,114);font-style:italic"> * This is a one to one copy of strcat test taken from StdLibTest.java test from OpenJDK</span></div><div><span style="color:rgb(95,102,114);font-style:italic"> */</span></div><div> <span style="color:rgb(229,192,123)">String</span> <span style="color:rgb(181,126,220)">strcat</span>(<span style="color:rgb(229,192,123)">String</span> <span style="color:rgb(198,204,215)">s1</span>, <span style="color:rgb(229,192,123)">String</span> <span style="color:rgb(198,204,215)">s2</span>) <span style="color:rgb(97,175,239)">throws</span> <span style="color:rgb(229,192,123)">Throwable</span> {</div><div> <span style="color:rgb(224,108,117)">try</span> (<span style="color:rgb(97,175,239)">var</span> <span style="color:rgb(198,204,215)">arena</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">Arena</span>.<span style="color:rgb(181,126,220)">openConfined</span>()) {</div><div> <span style="color:rgb(229,192,123)">MemorySegment</span> <span style="color:rgb(198,204,215)">buf</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">arena</span>.<span style="color:rgb(181,126,220)">allocate</span>(<span style="color:rgb(198,204,215)">s1</span>.<span style="color:rgb(181,126,220)">length</span>() <span style="color:rgb(224,108,117)">+</span> <span style="color:rgb(198,204,215)">s2</span>.<span style="color:rgb(181,126,220)">length</span>() <span style="color:rgb(224,108,117)">+</span> <span style="color:rgb(86,182,194)">1</span>);</div><div> <span style="color:rgb(198,204,215)">buf</span>.<span style="color:rgb(181,126,220)">setUtf8String</span>(<span style="color:rgb(86,182,194)">0</span>, <span style="color:rgb(198,204,215)">s1</span>);</div><div> <span style="color:rgb(229,192,123)">MemorySegment</span> <span style="color:rgb(198,204,215)">other</span> <span style="color:rgb(224,108,117)">=</span> <span style="color:rgb(198,204,215)">arena</span>.<span style="color:rgb(181,126,220)">allocateUtf8String</span>(<span style="color:rgb(198,204,215)">s2</span>);</div><div> <span style="color:rgb(224,108,117)">return</span> ((<span style="color:rgb(229,192,123)">MemorySegment</span>)<span style="color:rgb(198,204,215)">strcat</span>.<span style="color:rgb(181,126,220)">invokeExact</span>(<span style="color:rgb(198,204,215)">buf</span>, <span style="color:rgb(198,204,215)">other</span>)).<span style="color:rgb(181,126,220)">getUtf8String</span>(<span style="color:rgb(86,182,194)">0</span>);</div><div> }</div><div> }</div><div>}</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 3, 2023 at 12:55 PM Maurizio Cimadamore <<a href="mailto:maurizio.cimadamore@oracle.com">maurizio.cimadamore@oracle.com</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">Hi Bernd,<br>
this mailing list truncates attachments. If you want us to look at some <br>
code you will have to paste it somewhere :-)<br>
<br>
Cheers<br>
Maurizio<br>
<br>
On 03/01/2023 17:14, Bernd Müller wrote:<br>
> Dear all,<br>
><br>
> I try to train FFM. I even master quick sort but became desperate on <br>
> strcon.<br>
><br>
> Attached you will find a Maven project with the strcon test copied one <br>
> to one from<br>
> OpenJDK 20 sources.<br>
><br>
> "mvn test" results in<br>
><br>
> [ERROR] Errors:<br>
> [ERROR] StdLibTest.foo:49->strcat:60 » IndexOutOfBounds Out of bound <br>
> access on segment MemorySegment{ array: Optional.empty <br>
> address:139636573277136 limit: 0 }; new offset = 0; new length = 1<br>
><br>
> I am running OpenJDK 64-Bit Server VM (build 20-ea+29-2280, mixed <br>
> mode, sharing) on Fedora 36.<br>
><br>
> Please, can someone help ?<br>
><br>
> Kind Regards,<br>
><br>
> Bernd<br>
><br>
</blockquote></div>