Skip to content

Fatal runtime error and illegal instruction when compiling with LTO #11683

Closed
@dotdash

Description

@dotdash

After reading http://thornydev.blogspot.co.uk/2014/01/chinese-whispers-in-rust.html I tried to compile the example code with -Z lto. The resulting binary crashes with a fatal runtime error.

Code:

static N:int = 100000;

//
// Chinese Whispers in Rust
// Based on example by Rob Pike
// in http://www.youtube.com/watch?v=f6kdp27TYZs
//
fn main() {
    let (leftmost_port, leftmost_chan) = Chan::new();
    let mut leftc: Chan<int> = leftmost_chan;
    let mut rightp: Port<int>;

    for _ in range(0, N) {
        let (right_port, right_chan) = Chan::new();
        rightp = right_port;
        let c = leftc;
        let p = rightp;
        do spawn {
            whisper(c, p);
        }
        leftc = right_chan;
    }
    let rightmost_chan = leftc;
    do spawn {
        rightmost_chan.send(1);
    }
    println!("{}", leftmost_port.recv());
}

fn whisper(left: Chan<int>, right: Port<int>) {
    left.send( right.recv() + 1 );
}

Output without LTO:

$ ./chinese 
100001

Output with LTO:

$ ./chinese 



There are not many persons who know what wonders are opened to them in the
stories and visions of their youth; for when as children we listen and dream,
we think but half-formed thoughts, and when as men we try to remember, we are
dulled and prosaic with the poison of life. But some of us awake in the night
with strange phantasms of enchanted hills and gardens, of fountains that sing
in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
down to sleeping cities of bronze and stone, and of shadowy companies of heroes
that ride caparisoned white horses along the edges of thick forests; and then
we know that we have looked back through the ivory gates into that world of
wonder which was ours before we were wise and unhappy.

fatal runtime error:  assertion failed: !ptr.is_null()
Illegal instruction

Sometimes the error message is printed more than once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions