Closed
Description
Write mod crash;
in libcore/core.rc
, and add libcore/crash.rs
:
#[test]
fn make_crash() {
struct defer {
x: &~();
new(x: &~()) { self.x = x; }
drop { // Get rid of the destructor and it doesn't crash.
}
}
let x = ~();
// If you just write let z = defer(~~()) it doesn't crash.
let z = defer(&x);
// If you just write util::ignore(defer(x)) it doesn't crash.
util::ignore(z);
// If you write "pure fn ignore<T>(+_x: T) { }" (i.e., exactly the same as
// it is in util) and call that instead, it doesn't crash.
}
Then make check-stage0-core
.
Backtrace:
#3 0x00007ffff671a626 in malloc_printerr (action=3, str="free(): invalid pointer", ptr=<optimized out>)
#4 0x00007ffff6f9800d in __morestack ()
#5 0x00007ffff6f87028 in call_on_c_stack (fn_ptr=0x7ffff6f85e80, args=0x7fffec101330, this=0x7fffe8105a50)
#6 call_upcall_on_c_stack (fn_ptr=0x7ffff6f85e80, args=0x7fffec101330, task=<optimized out>)
#7 upcall_exchange_free (ptr=<optimized out>)
#8 0x0000000000540107 in __test::tests::anon ()
#9 0x00007ffff768f581 in task::spawn_raw::make_child_wrapper::anon ()
#10 0x00007ffff76d8d3c in __morestack ()
#11 0x00007ffff6f84564 in task_start_wrapper (a=0x7fffe81068a0)
For the life of me I could not get it to work outside of coretest. I tried std and I tried in its own module. Probably this means it's related to #2912.