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

Weird lifetimes cause a segfault in safe code #121184

Closed
ithuleyho opened this issue Feb 16, 2024 · 2 comments
Closed

Weird lifetimes cause a segfault in safe code #121184

ithuleyho opened this issue Feb 16, 2024 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@ithuleyho
Copy link

This contrived example compiles just fine, but running it results in a segmentation fault:

static UNIT: &'static &'static () = &&();

fn foo<'a, 'b, T>(_: &'a &'b (), v: &'b T) -> &'a T { v }

fn bad<'a, T>(x: &'a T) -> &'static T {
    let f: fn(_, &'a T) -> &'static T = foo;
    f(UNIT, x)
}

fn main() {
    let r = bad(&Box::new(&10));
    dbg!(r);
}

Playground link

The problem occurs on multiple rustc versions.

@ithuleyho ithuleyho added the C-bug Category: This is a bug. label Feb 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 16, 2024
@lukas-code
Copy link
Member

duplicate of #25860

@ithuleyho
Copy link
Author

duplicate of #25860

Thanks, I tried to search for this but found no mention.

@ithuleyho ithuleyho closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants