<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt">Sorry&nbsp; for&nbsp; the&nbsp; confusion,&nbsp; the&nbsp; strings&nbsp; were&nbsp; null&nbsp; terminated&nbsp; but a<br>backslash got lost in the mail.&nbsp; The actual program was:<br><br>&nbsp;&nbsp;&nbsp; val printf = _import "printf": string * int -&gt; unit;<br>&nbsp;&nbsp;&nbsp; val () = printf ("You are a dog %d\n\000", 99)<br>&nbsp;&nbsp;&nbsp; val () = printf ("Hello silly %d\n\000", 123)<br><div><br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Wesley W. Terpstra &lt;wesley@terpstra.ca&gt;<br><b><span style="font-weight: bold;">To:</span></b> Henry Cejtin
 &lt;henry.cejtin@sbcglobal.net&gt;<br><b><span style="font-weight: bold;">Cc:</span></b> mlton@mlton.org<br><b><span style="font-weight: bold;">Sent:</span></b> Fri, February 4, 2011 2:32:00 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [MLton] MLton broken FFI on AMD64???<br></font><br>
<div class="gmail_quote">On Thu, Feb 3, 2011 at 11:46 PM, Henry Cejtin <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:henry.cejtin@sbcglobal.net" target="_blank" href="mailto:henry.cejtin@sbcglobal.net">henry.cejtin@sbcglobal.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

The following program segfaults when run:<br>
<br>
 &nbsp; &nbsp;val printf = _import "printf": string * int -&gt; unit;<br>
 &nbsp; &nbsp;val () = printf ("You are a dog %d0000", 99)<br>
 &nbsp; &nbsp;val () = printf ("Hello silly %d0000", 123)<br></blockquote><div><br>My first answer was: null terminate your string.<br></div></div><br>However, the segfault persists. If you replace "printf" with "test":<br>
void test(const char* s, int x) {<br>&nbsp; printf(s, x);<br>}<br>... it works.<br><br>The problem also only appears for me when I target amd64. i386 works.<br><br>
</div></div>
</div></body></html>