Skip to content

Crash dropping Arc #13

Closed
Closed
@rodrigorc

Description

@rodrigorc

I've had some crashes when dropping core::sync::Arc objects. After some debugging I tracked the issue down to a LLVM bug with the atomic substraction, that I reported here, but not reply yet :-(.

For now I worked around the LLVM bug with this hack:

diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs
index 8dfb19fa032..eb59616ada0 100644
--- a/src/libcore/sync/atomic.rs
+++ b/src/libcore/sync/atomic.rs
@@ -1577,7 +1577,8 @@ assert_eq!(foo.load(Ordering::SeqCst), 10);
                 #[$stable]
                 #[cfg(target_has_atomic = "cas")]
                 pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type {
-                    unsafe { atomic_sub(self.v.get(), val, order) }
+                    unsafe { atomic_add(self.v.get(), val.wrapping_neg(), order) }
                 }
             }

I admit that this is not pretty, I'd rather modify atomic_sub() itself, but it is too generic to fix it easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions