free the borrow list propertly instead of crashing
This commit is contained in:
parent
4999d44d5b
commit
cc62680cc9
@ -15,6 +15,7 @@ use ptr::mut_null;
|
||||
use repr::BoxRepr;
|
||||
use sys::TypeDesc;
|
||||
use cast::transmute;
|
||||
use unstable::lang::clear_task_borrow_list;
|
||||
|
||||
#[cfg(notest)] use ptr::to_unsafe_ptr;
|
||||
|
||||
@ -179,6 +180,10 @@ pub unsafe fn annihilate() {
|
||||
n_bytes_freed: 0
|
||||
};
|
||||
|
||||
// Quick hack: we need to free this list upon task exit, and this
|
||||
// is a convenient place to do it.
|
||||
clear_task_borrow_list();
|
||||
|
||||
// Pass 1: Make all boxes immortal.
|
||||
//
|
||||
// In this pass, nothing gets freed, so it does not matter whether
|
||||
|
@ -91,7 +91,16 @@ fn swap_task_borrow_list(f: &fn(~[BorrowRecord]) -> ~[BorrowRecord]) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
|
||||
pub unsafe fn clear_task_borrow_list() {
|
||||
// pub because it is used by the box annihilator.
|
||||
let cur_task = rust_get_task();
|
||||
let ptr = rustrt::rust_take_task_borrow_list(cur_task);
|
||||
if !ptr.is_null() {
|
||||
let _: ~[BorrowRecord] = transmute(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
|
||||
debug_ptr("fail_borrowed: ", box);
|
||||
|
||||
if !::rt::env::get().debug_borrows {
|
||||
|
Loading…
x
Reference in New Issue
Block a user