Skip to content

Segfault in unstable::lang::return_to_mut #5517

Closed
@bblum

Description

@bblum

Found this while attempting to reproduce #3039. This code crashes:

fn main() {
    let box1 = @mut 42; 
    let _x = *(&mut *box1) == 42 || *(&mut *box1) == 31337;
}

This is as minimal as I can make it. Removing the second clause of the || makes it not crash. Changing the || to a && makes it not crash.

The backtrace is:

#0  0x00000000004011f8 in unstable::lang::return_to_mut::_a65ca8bc2b2b29c3::_00 ()
#1  0x0000000000400c07 in main::_eaf8b750790f65::_00 ()
#2  0x0000000000400e1e in _rust_main ()
#3  0x00007ffff74833b4 in task_start_wrapper (a=<optimized out>)
    at /home/bblum/rust/src/rt/rust_task.cpp:162
#4  0x0000000000000000 in ?? ()

It crashes where it is trying to read (*a).header.ref_count because a is a null pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsA-type-systemArea: Type systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions