-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Description
The following creates a dangling pointer to an outer stack frame:
use std::cell::Cell;
struct Foo<'a> {
x: int,
y: Cell<Option<&'a int>>,
}
fn f() -> Foo {
Foo {
x: 1,
y: Cell::new(None),
}
}
fn g<'a>(x: &'a Foo<'a>) {
x.y.set(Some(&x.x));
}
fn h() -> Foo {
let x = f();
g(&x);
x
}
fn main() {
let x = h();
// kaboom
}
This manifested as a rustc segfault.
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.