about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2013-08-02 16:06:13 -0400
committerBen Blum <bblum@andrew.cmu.edu>2013-08-02 17:31:45 -0400
commitd30cca46e61f8e5e604a87f0e623cb852be6c85f (patch)
treee42f180c70df6dc196d91c1e85f6324f470fa4b4 /src/libstd/rt
parentcde6ad39920ddadd7c70921232ae92adff258367 (diff)
downloadrust-d30cca46e61f8e5e604a87f0e623cb852be6c85f.tar.gz
rust-d30cca46e61f8e5e604a87f0e623cb852be6c85f.zip
Fix embarrassing bug where 'unkillable' would unwind improperly when it receives a kill signal.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/kill.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs
index 696f4a8c355..6c450971cdc 100644
--- a/src/libstd/rt/kill.rs
+++ b/src/libstd/rt/kill.rs
@@ -548,11 +548,12 @@ impl Death {
     /// All calls must be paired with a subsequent call to allow_kill.
     #[inline]
     pub fn inhibit_kill(&mut self, already_failing: bool) {
-        if self.unkillable == 0 {
+        self.unkillable += 1;
+        // May fail, hence must happen *after* incrementing the counter
+        if self.unkillable == 1 {
             rtassert!(self.kill_handle.is_some());
             self.kill_handle.get_mut_ref().inhibit_kill(already_failing);
         }
-        self.unkillable += 1;
     }
 
     /// Exit a possibly-nested unkillable section of code.