Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borrowed @mut boxes are not unborrowed during unwinding #7049

Closed
brson opened this issue Jun 11, 2013 · 4 comments
Closed

Borrowed @mut boxes are not unborrowed during unwinding #7049

brson opened this issue Jun 11, 2013 · 4 comments
Labels
A-codegen Area: Code generation

Comments

@brson
Copy link
Contributor

brson commented Jun 11, 2013

use std::task::spawn_unlinked;
use std::unstable::finally::Finally;

fn main() {
    let (port, chan) = stream();
    do spawn_unlinked {
        let buf = @mut ~[0];
        do (|| {
            fn take(_b: &mut ~[uint]) {
                fail!();
            }
            take(&mut *buf);
        }).finally {
            // This fails because buf is already borrowed
            let x = &*buf;
            assert!(*x == ~[0]);
            chan.send(());
        }
    }

    // This will fail if the finally block doesn't complete
    port.recv();
}
@brson
Copy link
Contributor Author

brson commented Jun 11, 2013

This will also leak one of the two thrown exceptions but that's a different bug.

@nikomatsakis
Copy link
Contributor

This is a pretty trivial fix I suspect. the code in middle/trans/write_guard.rs specifies that the "return_to_mut" cleanup only occurs on the non-fail path.

@emberian
Copy link
Member

emberian commented Aug 1, 2013

Triage bump

@thestinger
Copy link
Contributor

There are no more @mut pointers.

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
Remove `match_path` and `match_qpath`

The only remaining usage is the `author` lint, so the functions are left in for now. The test result for `repl_uninit` changed, the lint was broken before.

The `collapsible_span_lint_calls` and `match_type_on_diag_item` tests have been changed. Both lints were broken when utils was extracted into it's own crate. `match_type_on_diag_item` isn't quite fixed, but it's at least less broken.

changelog: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation
Projects
None yet
Development

No branches or pull requests

4 participants