Skip to content

Using inference to coerce a closure to a trait object on the result of a match causes segfault #20717

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

Closed
renato-zannon opened this issue Jan 7, 2015 · 2 comments

Comments

@renato-zannon
Copy link
Contributor

Now that's a convoluted title :)

This was reported by user krdln on reddit.

I'm using:

rustc 1.0.0-nightly (ea6f65c5f 2015-01-06 19:47:08 +0000)
binary: rustc
commit-hash: ea6f65c5f1a3f84e010d2cef02a0160804e9567a
commit-date: 2015-01-06 19:47:08 +0000
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

Minimal example:

fn main() {
    let _f: Box<Fn()> = match 0 { 
        0 => box || {}, 
        _ => box || {}
    };  
}

GDB backtrace:

#0  0x0000000000000000 in ?? ()
#1  0x00005555555592f0 in Box$LT$core..ops..Fn$LP$$RP$$GT$::glue_drop.1074::h5c0bbc43321199cc ()
#2  0x0000555555558e32 in bug::main () at bug.rs:2
#3  0x0000555555564239 in rust_try_inner ()
#4  0x0000555555564226 in rust_try ()
#5  0x0000555555561bcf in rt::lang_start::h50187c8fd9c16c7bLaz ()
#6  0x0000555555558fa5 in main ()

Interestingly, this (AFAIU) semantically equivalent program doesn't segfault:

fn main() {
    let _f = match 0 {
        0 => (box || {}) as Box<Fn()>,
        _ => (box || {}) as Box<Fn()>
    };  
}
@huonw
Copy link
Member

huonw commented Jan 7, 2015

Dupe of #20419. Thanks for filing!

@huonw huonw closed this as completed Jan 7, 2015
@renato-zannon
Copy link
Contributor Author

Oops, sorry about the dupe!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants