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

Regioned destructors don't run in the right order #3164

Closed
bblum opened this issue Aug 9, 2012 · 2 comments
Closed

Regioned destructors don't run in the right order #3164

bblum opened this issue Aug 9, 2012 · 2 comments
Labels
A-destructors Area: Destructors (`Drop`, …) A-lifetimes Area: Lifetimes / regions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@bblum
Copy link
Contributor

bblum commented Aug 9, 2012

I believe the issue is simply that destructors are run in regardless order of borrows. Instead, the destructors with borrows should run first.

This code prints, rust: ~"bye \xffffff91"

class defer {
    x: &str;
    new(x: &str) { self.x = x; }
    drop { #error["%s", self.x]; }
}

fn main() {
    let _x = defer(~"Goodbye world!");
    #error["..."];
}

and this code segfaults:

class defer {
    x: &[&str];
    new(x: &[&str]) { self.x = x; }
    drop { #error["%?", self.x]; }
}

fn main() {
    let _x = defer(~["Goodbye", "world!"]);
}
@bblum
Copy link
Contributor Author

bblum commented Aug 9, 2012

Dup of #2977

@nikomatsakis
Copy link
Contributor

This currently fails with "illegal borrow", as of ea549e7

saethlin pushed a commit to saethlin/rust that referenced this issue Nov 17, 2023
freebsd adding getrandom interception.

note that os support was added in same time as getentropy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-lifetimes Area: Lifetimes / regions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

2 participants