Closed
Description
The following code is miscompiled on my OS X laptop:
use std;
native "cdecl" mod libc = "" {
fn printf(s: *u8, a: int); /* A tenuous definition, indeed. Herp, derp. */
}
fn main() {
let b = std::str::bytes("%d\n");
let b8 = unsafe { std::vec::unsafe::to_ptr(b) };
libc::printf(b8, 4);
let a = bind libc::printf(b8, 5);
a(); /* core dump */
}
I also reproed on my Linux machine, in which I captured this GDB session:
(gdb) break printf
Breakpoint 1 at 0x8048b78
(gdb) run
Starting program: /storage/homes/joshua/rust/build/bindbad
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 0xf7917b70 (LWP 15444)]
[Switching to Thread 0xf7917b70 (LWP 15444)]
Breakpoint 1, __printf (format=0x804ca68 "%d\n") at printf.c:29
29 printf.c: No such file or directory.
in printf.c
(gdb) c
Continuing.
4
Breakpoint 1, __printf (format=0x10 <Address 0x10 out of bounds>) at printf.c:29
29 in printf.c
(gdb)
Metadata
Metadata
Assignees
Labels
No labels