Closed
Description
While implementing explanation for E0391 error (unsupported cyclic reference between types/traits detected) realized, that Rust from master branch fails to compile the following code sample:
trait A : B {}
trait B : A {}
fn main() {}
Output:
$ rustc ../main/src/main.rs
../main/src/main.rs:1:1: 1:15 error: unsupported cyclic reference between types/traits detected [E0391]
../main/src/main.rs:1 trait A : B {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `A`...
note: ...which then requires computing the supertraits of `B`...
note: ...which then again requires computing the supertraits of `A`, completing the cycle.
../main/src/main.rs:2:1: 2:15 error: unsupported cyclic reference between types/traits detected [E0391]
../main/src/main.rs:2 trait B : A {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `B`...
note: ...which then requires computing the supertraits of `A`...
note: ...which then again requires computing the supertraits of `B`, completing the cycle.
error: aborting due to 2 previous errors
fatal runtime error: Could not unwind stack, error = 5
[1] 13360 illegal hardware instruction (core dumped) rustc ../main/src/main.rs
Meta:
$ rustc --version --verbose
rustc 1.3.0-dev (a5c12f4e3 2015-07-26)
binary: rustc
commit-hash: a5c12f4e39d32af3c951b66bd2839bc0b5a1125b
commit-date: 2015-07-26
host: x86_64-unknown-linux-gnu
release: 1.3.0-dev
$ uname -a
Linux archlinux 3.14.41-1-lts #1 SMP Thu May 7 22:00:09 CEST 2015 x86_64 GNU/Linux
Valgrind output:
$ valgrind rustc ../main/src/main.rs
==14911== Memcheck, a memory error detector
==14911== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==14911== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==14911== Command: rustc ../main/src/main.rs
==14911==
==14911== Warning: client switching stacks? SP change: 0xffefff8c0 --> 0xffedddc48
==14911== to suppress, use: --max-stackframe=2235512 or greater
==14911== Syscall param read(buf) points to unaddressable byte(s)
==14911== at 0x4018327: read (in /usr/lib/ld-2.21.so)
==14911== by 0x400589E: open_verify (in /usr/lib/ld-2.21.so)
==14911== by 0x4005C41: open_path (in /usr/lib/ld-2.21.so)
==14911== by 0x4008606: _dl_map_object (in /usr/lib/ld-2.21.so)
==14911== by 0x400CB51: openaux (in /usr/lib/ld-2.21.so)
==14911== by 0x400F0A3: _dl_catch_error (in /usr/lib/ld-2.21.so)
==14911== by 0x400CDAF: _dl_map_object_deps (in /usr/lib/ld-2.21.so)
==14911== by 0x4002FEC: dl_main (in /usr/lib/ld-2.21.so)
==14911== by 0x40163F4: _dl_sysdep_start (in /usr/lib/ld-2.21.so)
==14911== by 0x4004DC9: _dl_start (in /usr/lib/ld-2.21.so)
==14911== by 0x4000D87: ??? (in /usr/lib/ld-2.21.so)
==14911== by 0x1: ???
==14911== Address 0xffedddc50 is on thread 1's stack
==14911== in frame #1, created by open_verify (???)
==14911==
==14911== Warning: client switching stacks? SP change: 0xffedddc50 --> 0xffefff8e8
==14911== to suppress, use: --max-stackframe=2235544 or greater
==14911== Warning: client switching stacks? SP change: 0xffefff4e0 --> 0xffec878e8
==14911== to suppress, use: --max-stackframe=3636216 or greater
==14911== further instances of this message will not be shown.
==14911== Thread 2 rustc:
==14911== Conditional jump or move depends on uninitialised value(s)
==14911== at 0x521823A: fs::Path.PathExt::exists::h0164ce7d2b6d29ee3of (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0xBD7B0B2: terminfo::searcher::get_dbpath_for_term::hfbe388e762e85e5dRba (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libterm-7e44814b.so)
==14911== by 0xBD7C05A: terminfo::searcher::open::hf8ec384aff46b792Lfa (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libterm-7e44814b.so)
==14911== by 0xBD8795C: terminfo::TerminfoTerminal$LT$T$GT$::new::h1432558803182259644 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libterm-7e44814b.so)
==14911== by 0xBD8A6D8: stderr::h952b4a1129d0474dPcc (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libterm-7e44814b.so)
==14911== by 0x79B6C17: diagnostic::EmitterWriter::stderr::h8634b5b7a28bf640mwB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x79B6A3D: diagnostic::Handler::new::h62024d48b0108e444hB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x70AE4A2: session::build_session::hab9a5f01a6d1f9d2Adu (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x4F12C8E: run_compiler::h568382d99291f1f6A7b (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4F10F89: boxed::F.FnBox$LT$A$GT$::call_box::h7408248526147125355 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4F108A9: rt::unwind::try::try_fn::h7368129329132908943 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x523399D: rt::unwind::try::inner_try::hb999e55d710629abIXw (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911==
==14911== Conditional jump or move depends on uninitialised value(s)
==14911== at 0x521823A: fs::Path.PathExt::exists::h0164ce7d2b6d29ee3of (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x7096E57: metadata::filesearch::find_libdir::h58b61544ccad0c29cUq (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x7097154: metadata::filesearch::relative_target_lib_path::h21747527b6439687SNq (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x708A2E3: metadata::loader::Context$LT$$u27$a$GT$::find_library_crate::h9eeb346b203c7528qFp (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x7083668: metadata::creader::CrateReader$LT$$u27$a$GT$::read_extension_crate::h39642a93a936fdbbEko (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x70851E3: metadata::creader::CrateReader$LT$$u27$a$GT$::read_exported_macros::haf83ac426f3a3c46yoo (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x7099624: metadata::macro_import::MacroLoader$LT$$u27$a$GT$.Visitor$LT$$u27$v$GT$::visit_item::hf3409ff34bad58e6pXq (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x709865E: metadata::macro_import::read_macro_defs::h97c4775e35518826bWq (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x4E578D2: driver::phase_2_configure_and_expand::h407a6d549af07a86ita (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4E4A526: driver::compile_input::h22e2cbe3c4ef0b98Tba (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4F1329F: run_compiler::h568382d99291f1f6A7b (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4F10F89: boxed::F.FnBox$LT$A$GT$::call_box::h7408248526147125355 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911==
../main/src/main.rs:1:1: 1:15 error: unsupported cyclic reference between types/traits detected [E0391]
../main/src/main.rs:1 trait A : B {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `A`...
note: ...which then requires computing the supertraits of `B`...
note: ...which then again requires computing the supertraits of `A`, completing the cycle.
../main/src/main.rs:2:1: 2:15 error: unsupported cyclic reference between types/traits detected [E0391]
../main/src/main.rs:2 trait B : A {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `B`...
note: ...which then requires computing the supertraits of `A`...
note: ...which then again requires computing the supertraits of `B`, completing the cycle.
error: aborting due to 2 previous errors
fatal runtime error: Could not unwind stack, error = 5
==14911== valgrind: Unrecognised instruction at address 0x52450e4.
==14911== at 0x52450E4: rt::util::abort::h5db1a7f553146c79sOw (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x52451C3: rt::unwind::imp::panic::hebe123db5ed49994lQw (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x524531A: rust_panic (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x520EEBA: rt::unwind::begin_unwind_inner::hde1efbc08f86364410w (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x798040C: rt::unwind::begin_unwind::h16599013175360289856 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x79B718D: diagnostic::Handler::fatal::h8d7c60aba1ceabf2QiB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x79B7BA2: diagnostic::Handler::abort_if_errors::h9debaf1623f3292bxkB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x6E8E765: session::Session::abort_if_errors::h270cfb69963aa9de0Vt (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x5C61E2E: check_crate::h3789e2799f00c399QdD (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_typeck-7e44814b.so)
==14911== by 0x4E66FE9: driver::phase_3_run_analysis_passes::closure.16500 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4E6584B: driver::phase_3_run_analysis_passes::h12527889505207664615 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4E4BC8E: driver::compile_input::h22e2cbe3c4ef0b98Tba (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== Your program just tried to execute an instruction that Valgrind
==14911== did not recognise. There are two possible reasons for this.
==14911== 1. Your program has a bug and erroneously jumped to a non-code
==14911== location. If you are running Memcheck and you just saw a
==14911== warning about a bad jump, it's probably your program's fault.
==14911== 2. The instruction is legitimate but Valgrind doesn't handle it,
==14911== i.e. it's Valgrind's fault. If you think this is the case or
==14911== you are not sure, please let us know and we'll try to fix it.
==14911== Either way, Valgrind will now raise a SIGILL signal which will
==14911== probably kill your program.
==14911==
==14911== Process terminating with default action of signal 4 (SIGILL)
==14911== Illegal opcode at address 0x52450E4
==14911== at 0x52450E4: rt::util::abort::h5db1a7f553146c79sOw (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x52451C3: rt::unwind::imp::panic::hebe123db5ed49994lQw (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x524531A: rust_panic (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x520EEBA: rt::unwind::begin_unwind_inner::hde1efbc08f86364410w (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libstd-7e44814b.so)
==14911== by 0x798040C: rt::unwind::begin_unwind::h16599013175360289856 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x79B718D: diagnostic::Handler::fatal::h8d7c60aba1ceabf2QiB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x79B7BA2: diagnostic::Handler::abort_if_errors::h9debaf1623f3292bxkB (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/libsyntax-7e44814b.so)
==14911== by 0x6E8E765: session::Session::abort_if_errors::h270cfb69963aa9de0Vt (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc-7e44814b.so)
==14911== by 0x5C61E2E: check_crate::h3789e2799f00c399QdD (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_typeck-7e44814b.so)
==14911== by 0x4E66FE9: driver::phase_3_run_analysis_passes::closure.16500 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4E6584B: driver::phase_3_run_analysis_passes::h12527889505207664615 (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911== by 0x4E4BC8E: driver::compile_input::h22e2cbe3c4ef0b98Tba (in /home/soon/Src/Rust/rust/x86_64-unknown-linux-gnu/stage1/lib/librustc_driver-7e44814b.so)
==14911==
==14911== HEAP SUMMARY:
==14911== in use at exit: 334,940 bytes in 2,601 blocks
==14911== total heap usage: 12,955 allocs, 10,354 frees, 3,107,492 bytes allocated
==14911==
==14911== LEAK SUMMARY:
==14911== definitely lost: 80 bytes in 1 blocks
==14911== indirectly lost: 0 bytes in 0 blocks
==14911== possibly lost: 517 bytes in 5 blocks
==14911== still reachable: 334,343 bytes in 2,595 blocks
==14911== suppressed: 0 bytes in 0 blocks
==14911== Rerun with --leak-check=full to see details of leaked memory
==14911==
==14911== For counts of detected and suppressed errors, rerun with: -v
==14911== Use --track-origins=yes to see where uninitialised values come from
==14911== ERROR SUMMARY: 12 errors from 3 contexts (suppressed: 4 from 2)
[1] 14911 killed valgrind rustc ../main/src/main.rs
Also, Rust 1.1 from AUR compiles the code above without any problems:
$ rustc src/main.rs
src/main.rs:1:1: 1:15 error: unsupported cyclic reference between types/traits detected
src/main.rs:1 trait A : B {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `A`...
note: ...which then requires computing the supertraits of `B`...
note: ...which then again requires computing the supertraits of `A`, completing the cycle.
src/main.rs:2:1: 2:15 error: unsupported cyclic reference between types/traits detected
src/main.rs:2 trait B : A {}
^~~~~~~~~~~~~~
note: the cycle begins when computing the supertraits of `B`...
note: ...which then requires computing the supertraits of `A`...
note: ...which then again requires computing the supertraits of `B`, completing the cycle.
error: aborting due to 2 previous errors
$ rustc --version --verbose
rustc 1.1.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.1.0