Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal compiler error in trans, with bind and iterators #2185

Closed
gifnksm opened this issue Apr 11, 2012 · 2 comments
Closed

Internal compiler error in trans, with bind and iterators #2185

gifnksm opened this issue Apr 11, 2012 · 2 comments
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@gifnksm
Copy link
Contributor

gifnksm commented Apr 11, 2012

Compiling following source, rustc dumps core with error messages.

import iter::*;

fn main() {
    let range = bind uint::range(0u, 1000u, _);
    let filt  = bind iter::filter(range, {|&&n: uint| n % 3u != 0u && n % 5u != 0u }, _);
    let sum   = iter::foldl(filt, 0u) {|accum, &&n: uint| accum + n };

    io::println(#fmt("%u", sum));
}
$ rustc foo.rs
error: internal compiler error unexpected failure
note: The compiler hit an unexpected failure path. This is a bug. Try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
leaked memory in rust main loop (1 objects)
Assertion failed: (false), function ~memory_region, file ../src/rt/memory_region.cpp, line 172.
zsh: abort (core dumped)  rustc foo.rs
$ RUST_LOG=rustc=0,::rt::backtrace rustc foo.rs
rust: upcall fail 'explicit failure', ../src/rustc/rustc.rc:1
0x802197914 <_ZN9rust_task15call_on_c_stackEPvS0_+148> at /usr/local/bin/../lib/librustrt.so                                                                                                                                                                                     @&N0x8021986ed <upcall_fail+141> at /usr/local/bin/../lib/librustrt.so
�\0x8018dc7de <_ZN6middle2ty16lookup_item_type17_f614ca4c755aeba7202E+846> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                              �0x8018dbde1 <_ZN6middle5trans4base12make_mono_id17_f2ebd2e452b417a6202E+257> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x8018c7568 <_ZN6middle5trans4base14monomorphic_fn17_77d7254b93f76bc2202E+472> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
0x8018ee718 <_ZN6middle5trans4base20lval_static_fn_inner17_f1ee6671c5727412202E+488> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
��0x80193daf7 <_ZN6middle5trans4impl26trans_monomorphized_callee17_397545b5c646b954202E+999> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018d0f06 <_ZN6middle5trans4impl19trans_method_callee17_6b1587f014518324202E+470> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
@@�0x8018f61c4 <_ZN6middle5trans4base12trans_callee17_ed5afa7c661e67af202E+484> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801901487 <_ZN6middle5trans4base10with_scope17_13d2b9fa8bfa3e3f202E+583> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x801b7e11c <_ZN3lib4llvm16section_iter_res4dtor17_3815581a5148d851202E+396> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80190141c <_ZN6middle5trans4base10with_scope17_13d2b9fa8bfa3e3f202E+476> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018d0c96 <_ZN6middle5trans4base16trans_call_inner17_e4ab2a25f8e56a47202E+390> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                     @�0x8018fdf12 <_ZN6middle5trans4base10trans_call17_f759ff632d924a7a202E+258> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018d1c83 <_ZN6middle5trans4base10trans_expr17_2f49fb6e59efc0cc202E+3187> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80190a00f <_ZN6middle5trans4base10trans_stmt17_dda29e9b5a06725d202E+1103> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x8018d9fbf <_ZN6middle5trans4base11trans_block17_5d538f556387313f202E+303> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80190d9ed <_ZN6middle5trans4base13trans_closure17_f68d7bace7a25795202E+1197> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
0x8018e636d <_ZN6middle5trans4base8trans_fn17_30737349273ebd1b202E+461> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                                0x8018c8122 <_ZN6middle5trans4base14monomorphic_fn17_77d7254b93f76bc2202E+3474> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
@�0x8018ee718 <_ZN6middle5trans4base20lval_static_fn_inner17_f1ee6671c5727412202E+488> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
��0x8018ee272 <_ZN6middle5trans4base14lval_static_fn17_97c1e6b66444e182202E+418> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
0x8018f472d <_ZN6middle5trans4base9trans_var17_7c5ea379277185b4202E+205> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                                �0x8018f4556 <_ZN6middle5trans4base10trans_path17_c674ef35f426c629202E+198> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018f608b <_ZN6middle5trans4base12trans_callee17_ed5afa7c661e67af202E+171> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801901487 <_ZN6middle5trans4base10with_scope17_13d2b9fa8bfa3e3f202E+583> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8019012e7 <_ZN6middle5trans4base10with_scope17_13d2b9fa8bfa3e3f202E+167> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018d0c96 <_ZN6middle5trans4base16trans_call_inner17_e4ab2a25f8e56a47202E+390> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                     @��0x8018fdf12 <_ZN6middle5trans4base10trans_call17_f759ff632d924a7a202E+258> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8018d1c83 <_ZN6middle5trans4base10trans_expr17_2f49fb6e59efc0cc202E+3187> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801b7e11c <_ZN3lib4llvm16section_iter_res4dtor17_3815581a5148d851202E+396> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x8018d103c <_ZN6middle5trans4base10trans_expr17_2f49fb6e59efc0cc202E+44> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x8019083ad <_ZN6middle5trans4base10init_local17_17d57dd23a569e54202E+333> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x80190a1b5 <_ZN6middle5trans4base10trans_stmt17_dda29e9b5a06725d202E+1525> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80190a0ab <_ZN6middle5trans4base10trans_stmt17_dda29e9b5a06725d202E+1259> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x8018d9fbf <_ZN6middle5trans4base11trans_block17_5d538f556387313f202E+303> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80190d9ed <_ZN6middle5trans4base13trans_closure17_f68d7bace7a25795202E+1197> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
0x8018e636d <_ZN6middle5trans4base8trans_fn17_30737349273ebd1b202E+461> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                                0x8018ec8bb <_ZN6middle5trans4base10trans_item17_28e452dae21c3667202E+1883> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801911e94 <_ZN6middle5trans4base9trans_mod17_384418731efae2e8202E+260> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                               �0x80191dc28 <_ZN6middle5trans4base11trans_crate17_6616cfe44b3b9bb3202E+4600> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801b7e11c <_ZN3lib4llvm16section_iter_res4dtor17_3815581a5148d851202E+396> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x80191ca5c <_ZN6middle5trans4base11trans_crate17_6616cfe44b3b9bb3202E+44> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�\0x801b7e11c <_ZN3lib4llvm16section_iter_res4dtor17_3815581a5148d851202E+396> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so
�0x801b6182c <_ZN6driver6driver12compile_upto17_40784acf6e567faf202E+44> at /usr/local/bin/../lib/librustc-688fa7810161fd45-0.2.so                                                                                                                                               0x403f6a <_init+8218> at /usr/local/bin/rustc
@0�0x407818 <_rust_main+1464> at /usr/local/bin/rustc                                                                                                                                                                                                                             �0x402f1c <_init+4044> at /usr/local/bin/rustc
@��0x406878 <_init+18728> at /usr/local/bin/rustc
@�0x80089e675 <_ZN4task11get_task_id17_42c92e624d84fbbc202E+149> at /usr/local/bin/../lib/libcore-d27e4777a53c3e50-0.2.so
�0x802196735 <_Z18task_start_wrapperP10spawn_args+37> at /usr/local/bin/../lib/librustrt.so
@`�error: internal compiler error unexpected failure
note: The compiler hit an unexpected failure path. This is a bug. Try running with RUST_LOG=rustc=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: upcall fail 'explicit failure', ../src/rustc/driver/rustc.rs:187
0x802197914 <_ZN9rust_task15call_on_c_stackEPvS0_+148> at /usr/local/bin/../lib/librustrt.so                                                                                                                                                                                     @cM0x8021986ed <upcall_fail+141> at /usr/local/bin/../lib/librustrt.so
�\0x406388 <_init+17464> at /usr/local/bin/rustc
�F0x407818 <_rust_main+1464> at /usr/local/bin/rustc                                                                                                                                                                                                                              �0x405cdc <_init+15756> at /usr/local/bin/rustc
�E0x802196735 <_Z18task_start_wrapperP10spawn_args+37> at /usr/local/bin/../lib/librustrt.so
@�Erust: domain main @0x80443a810 root task failed
leaked memory in rust main loop (1 objects)
Assertion failed: (false), function ~memory_region, file ../src/rt/memory_region.cpp, line 172.
zsh: abort (core dumped)  RUST_LOG=rustc=0,::rt::backtrace rustc foo.rs
@catamorphism
Copy link
Contributor

I took the liberty of giving the bug a slightly more descriptive title, since rustc often dumps core after an internal compiler error.

@ghost ghost assigned catamorphism Apr 12, 2012
@catamorphism
Copy link
Contributor

I minimized the test case a tiny bit: https://gist.github.com/2466203

I'm seeing some behavior in trans::impl::trans_monomorphized_callee that looks weird to me. The actual ICE occurs in base:make_mono_id because for the iter method of the iter::iterable iface, bounds has length 1 and substs has length 2. It seems wrong to me that there would be two elements in substs: iter has one ty param, that is, the ty param of its parent iface. By inserting print statements into trans_monomorphized_callee, I noticed that ty_substs has length 2 in this case (and that's the list that eventually becomes the substs argument of make_mono_id). That looks wrong as well, so I'm suspicious about the line of code in trans_monomorphized_callee that computes ty_substs. impl_substs appears to be correct here (the impl of iterable for type fn@(fn(uint)) does indeed introduce one subst, uint for A), but I'm not sure why node_substs also maps to [uint].

Anyway, @marijnh said he would look at this further.

marijnh added a commit that referenced this issue Apr 25, 2012
(With the fix for #2185 included.)
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
…ust-lang#2185)

Changed how `kani-driver` passess arguments to `kani-compiler`. We now have one option, `--kani-compiler`, that changes how we configure rustc, and all the other Kani specific arguments are added to `-C llvm-args`. We no longer need to keep the arguments in a certain order or need to use KANI_FLAGS environment variable.

In the `kani-compiler` we no longer parse the arguments before invoking rustc, we initially detect whether users want to use the Kani flavour of the compiler by looking for a `--kani-compiler` flag.

If `--kani-compiler` flag is found, we configure rustc's driver to use our custom backend and our custom callback. We then invoke the driver with the command line arguments excluding the `--kani-compiler` flag. During the callback configuration we initialize the Kani specific flags that are passed via `-C llvm-args`.

If there isn't any `--kani-compiler` flag, we just invoke rustc with all the given arguments.


Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

3 participants