Skip to content

Commit 5fc4045

Browse files
committed
Don't make the runtime exit on illegal calls
1 parent c4093b4 commit 5fc4045

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

src/libstd/rt/kill.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,9 @@ impl Death {
647647
/// All calls must be paired with a preceding call to inhibit_kill.
648648
#[inline]
649649
pub fn allow_kill(&mut self, already_failing: bool) {
650-
rtassert!(self.unkillable != 0);
650+
if self.unkillable == 0 {
651+
fail!("illegal call of rekillable");
652+
}
651653
self.unkillable -= 1;
652654
if self.unkillable == 0 {
653655
rtassert!(self.kill_handle.is_some());

src/libstd/task/mod.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,39 @@ fn test_kill_rekillable_task() {
671671
}
672672
}
673673

674-
#[test] #[should_fail]
674+
#[test]
675+
#[ignore(cfg(windows))]
676+
#[should_fail]
677+
fn test_rekillable_not_nested() {
678+
do rekillable {
679+
// This should fail before
680+
// receiving anything since
681+
// this block should be nested
682+
// into a unkillable block.
683+
yield();
684+
}
685+
}
686+
687+
688+
#[test]
689+
#[ignore(cfg(windows))]
690+
fn test_rekillable_nested_failure() {
691+
692+
let result = do task::try {
693+
do unkillable {
694+
do rekillable {
695+
let (port,chan) = comm::stream();
696+
do task::spawn { chan.send(()); fail!(); }
697+
port.recv(); // wait for child to exist
698+
port.recv(); // block forever, expect to get killed.
699+
}
700+
}
701+
};
702+
assert!(result.is_err());
703+
}
704+
705+
706+
#[test] #[should_fail] #[ignore(cfg(windows))]
675707
fn test_cant_dup_task_builder() {
676708
let mut builder = task();
677709
builder.unlinked();
@@ -1239,20 +1271,6 @@ fn test_unkillable_nested() {
12391271
po.recv();
12401272
}
12411273

1242-
#[ignore(reason = "linked failure")]
1243-
#[test]
1244-
#[ignore(cfg(windows))]
1245-
#[should_fail]
1246-
fn test_rekillable_not_nested() {
1247-
do rekillable {
1248-
// This should fail before
1249-
// receiving anything since
1250-
// this block should be nested
1251-
// into a unkillable block.
1252-
yield();
1253-
}
1254-
}
1255-
12561274
#[test]
12571275
fn test_child_doesnt_ref_parent() {
12581276
// If the child refcounts the parent task, this will stack overflow when

src/llvm

Submodule llvm updated 5382 files

0 commit comments

Comments
 (0)