Closed

Description
Running this test.rs
causes a segfault on Ubuntu 12.10 (compiled with incoming bda4dd3):
enum Foo {
Bar,
Baz {a: uint}
}
impl Foo {
fn equals(&self, other: &Foo) -> bool {
match *self {
Bar => match *other { Bar => true, _ => false },
Baz {a: ref sa} => match *other {
Baz {a: ref oa} => sa == oa,
_ => false
}
}
}
}
pub fn main() {
let x = Baz {a: 4};
let y = Bar;
x.equals(&y);
}
Valgrind says this about it:
==16637== Thread 2:
==16637== Use of uninitialised value of size 8
==16637== at 0x400AE8: uint::__extensions__::meth_2509::eq::_693b4a7b2ad824e5::_00 (test.rs:1)
==16637== by 0x400A9D: ptr::__extensions__::eq_2502::_37b8589111841e1::_00 (test.rs:1)
==16637== by 0x400A3B: __extensions__::meth_2459::equals::_e3a12daf95a36916::_00 (test.rs:11)
==16637== by 0x400B68: main::_6706ae2286769fe::_00 (test.rs:21)
==16637== by 0x400B9D: _rust_main (test.rs:12)
==16637== by 0x535E4C3: task_start_wrapper(spawn_args*) (rust_task.cpp:162)
==16637==
==16637== Invalid read of size 8
==16637== at 0x400AE8: uint::__extensions__::meth_2509::eq::_693b4a7b2ad824e5::_00 (test.rs:1)
==16637== by 0x400A9D: ptr::__extensions__::eq_2502::_37b8589111841e1::_00 (test.rs:1)
==16637== by 0x400A3B: __extensions__::meth_2459::equals::_e3a12daf95a36916::_00 (test.rs:11)
==16637== by 0x400B68: main::_6706ae2286769fe::_00 (test.rs:21)
==16637== by 0x400B9D: _rust_main (test.rs:12)
==16637== by 0x535E4C3: task_start_wrapper(spawn_args*) (rust_task.cpp:162)
==16637== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==16637==
==16637==
==16637== Process terminating with default action of signal 11 (SIGSEGV)
==16637== Access not within mapped region at address 0x0
==16637== at 0x400AE8: uint::__extensions__::meth_2509::eq::_693b4a7b2ad824e5::_00 (test.rs:1)
==16637== by 0x400A9D: ptr::__extensions__::eq_2502::_37b8589111841e1::_00 (test.rs:1)
==16637== by 0x400A3B: __extensions__::meth_2459::equals::_e3a12daf95a36916::_00 (test.rs:11)
==16637== by 0x400B68: main::_6706ae2286769fe::_00 (test.rs:21)
==16637== by 0x400B9D: _rust_main (test.rs:12)
==16637== by 0x535E4C3: task_start_wrapper(spawn_args*) (rust_task.cpp:162)
Note that the following variants of the last line of main
do not cause a segfault:
x.equals(&x);
y.equals(&y);
y.equals(&x);