diff options
author | Bert Belder <bertbelder@gmail.com> | 2018-10-03 01:10:57 -0700 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2018-10-03 13:27:59 -0700 |
commit | 97e08a6fab3569e75cc273ce9da6fb44c1295f0a (patch) | |
tree | 42b2a2c52cb1631a3e740c39c39ee74111f37fe3 /src | |
parent | 4eeda9ea278f7b3b88d681e56a14666dc7e76548 (diff) |
isolate: work around a rust compiler bug
Diffstat (limited to 'src')
-rw-r--r-- | src/isolate.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/isolate.rs b/src/isolate.rs index 0976bd765..ddda96f99 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -14,6 +14,7 @@ use libc::c_void; use std; use std::ffi::CStr; use std::ffi::CString; +use std::sync::atomic; use std::sync::mpsc; use std::sync::Arc; use std::sync::Mutex; @@ -193,6 +194,14 @@ impl Isolate { } fn ntasks_decrement(&mut self) { + // Do something that has no effect. This is done to work around a spooky + // bug that happens in release mode only (presumably a compiler bug), that + // causes nsize to unexpectedly contain zero. + // TODO: remove this workaround when no longer necessary. + #[allow(unused)] + static UNUSED: atomic::AtomicIsize = atomic::AtomicIsize::new(0); + UNUSED.fetch_add(self.ntasks as isize, atomic::Ordering::AcqRel); + // Actually decrement the tasks counter here. self.ntasks = self.ntasks - 1; assert!(self.ntasks >= 0); } |