Skip to content

segfault on trivial usage of MutexARC<int> #5419

Closed

Description

@danglick

Following program segfaults using rust 0.5 on Fedora 17:

extern mod std;

use core::task::;
use std::
;

fn main() {
let value = 0;
let marc = arc::MutexARC(value);

for int::range(0, 5) |_| {
do spawn {
do marc.access |v| { *v += 1; }
}
}
}

Activity

  1. thestinger commented on Mar 17, 2013

    @thestinger
    Contributor

    @danglick: The code doesn't compile with master/incoming.

    foo.rs:12:3: 12:7 error: illegal by-move capture of captured outer immutable variable in a stack closure
    foo.rs:12 do marc.access |v| { *v += 1; }
    
  2. danglick commented on Mar 17, 2013

    @danglick
    Author

    Sorry, rust newbie error, I was missing the call to marc.clone(). Glad that the compiler has now been fixed to protect me from myself. :)

  3. added 2 commits that reference this issue on May 2, 2020
  4. added a commit that references this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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