<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 for the confusion, the strings were null terminated but a<br>backslash got lost in the mail. The actual program was:<br><br> val printf = _import "printf": string * int -> unit;<br> val () = printf ("You are a dog %d\n\000", 99)<br> 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 <wesley@terpstra.ca><br><b><span style="font-weight: bold;">To:</span></b> Henry Cejtin
<henry.cejtin@sbcglobal.net><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"><<a rel="nofollow" ymailto="mailto:henry.cejtin@sbcglobal.net" target="_blank" href="mailto:henry.cejtin@sbcglobal.net">henry.cejtin@sbcglobal.net</a>></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>
val printf = _import "printf": string * int -> unit;<br>
val () = printf ("You are a dog %d0000", 99)<br>
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> 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>