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

by-val and by-move can be dangerous when combined #2443

Closed
nikomatsakis opened this issue May 25, 2012 · 2 comments
Closed

by-val and by-move can be dangerous when combined #2443

nikomatsakis opened this issue May 25, 2012 · 2 comments
Labels
A-lifetimes Area: Lifetimes / regions
Milestone

Comments

@nikomatsakis
Copy link
Contributor

Currently, the compiler does not account for the fact that "by value" passing of ref-counted boxes is in fact a borrow. This can be fixed easily enough in borrowck (or, I imagine, in alias). In any case, I added an xfail'd test (by-val-and-by-move.rs) that demonstrates the problem. This test fails (note the environment variable RUST_POISON_ON_FREE---without that, the test may accidentally pass even though it is accessing a freed pointer).

// xfail-test
// exec-env:RUST_POISON_ON_FREE

fn it_takes_two(x: @int, -y: @int) -> int {
    free(y);
    #debug["about to deref"];
    *x
}

fn free<T>(-t: T) {
}

fn main() {
    let z = @3;
    assert 3 == it_takes_two(z, z);
}
nikomatsakis added a commit that referenced this issue May 25, 2012
@nikomatsakis
Copy link
Contributor Author

just realized---this should be easy to fix with borrowck, but we don't handle it now. we don't seem to get the scope right when checking that there is no move from a borrow ptr.

@graydon
Copy link
Contributor

graydon commented Aug 31, 2012

Obsolete given scheduled removal of modes (or at least WONTFIX).

@graydon graydon closed this as completed Aug 31, 2012
jbclements added a commit to jbclements/rust that referenced this issue Apr 3, 2013
jbclements added a commit to jbclements/rust that referenced this issue Apr 4, 2013
jbclements added a commit to jbclements/rust that referenced this issue Apr 10, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 13, 2023
Add `./miri run-dep` for running a file with test dependencies available

fixes rust-lang#2443
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jun 3, 2023
Hide full miri command line in `./miri run-dep`

fixes rust-lang#2443
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

2 participants