Closed dotdash closed 10 years ago
A smaller example that also triggers the error:
fn main() {
let (p, c) = Chan::<int>::new();
do spawn {
c.send(1);
}
println!("{}", p.recv());
}
What system are you running on and can you provide the exact invocations of rustc
? I'm unable to reproduce this on OSX and linux so far.
Reproduced on two (quite similar) i7-3770(K) systems. Both running an up-to-date Debian Sid.
uname -a
says Linux bs 3.12-1-amd64 #1 SMP Debian 3.12.6-2 (2013-12-29) x86_64 GNU/Linux
I just noticed that it doesn't fail if you don't pass -O
.
Invocation that triggers the failure:
bs@bs:rust-play $ rustc -O -Z lto issue11683.rs
bs@bs:rust-play $ ./issue11683
1
bs@bs:rust-play $ ./issue11683
1
bs@bs:rust-play $ ./issue11683
1
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
Well then. That's 6 hours of my life I'll never get back :)
Not exactly the bug I was expecting to find...
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:
Output without LTO:
Output with LTO:
Sometimes the error message is printed more than once.