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

ICE: pub extern fn with parameter type &str inside struct impl #28600

Closed
ryantaylor opened this issue Sep 23, 2015 · 2 comments
Closed

ICE: pub extern fn with parameter type &str inside struct impl #28600

ryantaylor opened this issue Sep 23, 2015 · 2 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@ryantaylor
Copy link

struct Test;

impl Test {
    pub extern fn test(val: &str) {

    }
}

When you attempt to compile you get:

thread 'rustc' panicked at 'assertion failed: index < LLVMCountParams(llfn)', ../src/librustc_llvm/lib.rs:2281

stack backtrace:
   1:     0x7f594732b6e9 - sys::backtrace::tracing::imp::write::hc20cecbe7cbc162bPnt
   2:     0x7f5947328c36 - panicking::on_panic::h838652421a384701enx
   3:     0x7f59472f3f9e - sys_common::unwind::begin_unwind_inner::h1941327c7a60c738ffs
   4:     0x7f5942add8bf - sys_common::unwind::begin_unwind::h10325064115155345230
   5:     0x7f5942ade6c8 - get_param::h41f15541bf012b4aDUc
   6:     0x7f594682b985 - trans::base::trans_closure::h9db23c69943cc6edvQi
   7:     0x7f594682ea4f - trans::base::trans_fn::he234bd1782c765fai0i
   8:     0x7f59468330ab - trans::base::trans_item::hdd4c4224f51d93be9qj
   9:     0x7f594683f989 - trans::base::trans_crate::hbcfdc768138ad4feRck
  10:     0x7f59478574dc - driver::phase_4_translate_to_llvm::h281d81b2d864b5a0lPa
  11:     0x7f5947851ba3 - driver::phase_3_run_analysis_passes::closure.21540
  12:     0x7f594782f27c - middle::ty::context::ctxt<'tcx>::create_and_enter::h14146594457946518047
  13:     0x7f594782aa31 - driver::phase_3_run_analysis_passes::h3931958423828830349
  14:     0x7f594780aded - driver::compile_input::h4f0a6e7bed616ea50ba
  15:     0x7f5947970d0b - run_compiler::ha3f4465c73f94406qqc
  16:     0x7f594796e576 - boxed::F.FnBox<A>::call_box::h9054381916092353385
  17:     0x7f594796de84 - sys_common::unwind::try::try_fn::h18243607356614407688
  18:     0x7f5947328538 - __rust_try
  19:     0x7f594731ccd2 - sys_common::unwind::try::inner_try::h074d3cf1bfeda6e7Dbs
  20:     0x7f594796e01e - boxed::F.FnBox<A>::call_box::h2812587830519910695
  21:     0x7f5947330a03 - sys::thread::Thread::new::thread_start::h745044ae17db5a99dGw
  22:     0x7f59412c64a3 - start_thread
  23:     0x7f5946fb813c - clone
  24:                0x0 - <unknown>

Also tested with the following:

use std::path::Path;

struct Test;

impl Test {
    pub extern fn test(val: &Path) {

    }
}

You get:

thread 'rustc' panicked at 'assertion failed: index < LLVMCountParams(llfn)', ../src/librustc_llvm/lib.rs:2281

stack backtrace:
   1:     0x7fab8a7b06e9 - sys::backtrace::tracing::imp::write::hc20cecbe7cbc162bPnt
   2:     0x7fab8a7adc36 - panicking::on_panic::h838652421a384701enx
   3:     0x7fab8a778f9e - sys_common::unwind::begin_unwind_inner::h1941327c7a60c738ffs
   4:     0x7fab85f628bf - sys_common::unwind::begin_unwind::h10325064115155345230
   5:     0x7fab85f636c8 - get_param::h41f15541bf012b4aDUc
   6:     0x7fab89cb0985 - trans::base::trans_closure::h9db23c69943cc6edvQi
   7:     0x7fab89cb3a4f - trans::base::trans_fn::he234bd1782c765fai0i
   8:     0x7fab89cb80ab - trans::base::trans_item::hdd4c4224f51d93be9qj
   9:     0x7fab89cc4989 - trans::base::trans_crate::hbcfdc768138ad4feRck
  10:     0x7fab8acdc4dc - driver::phase_4_translate_to_llvm::h281d81b2d864b5a0lPa
  11:     0x7fab8acd6ba3 - driver::phase_3_run_analysis_passes::closure.21540
  12:     0x7fab8acb427c - middle::ty::context::ctxt<'tcx>::create_and_enter::h14146594457946518047
  13:     0x7fab8acafa31 - driver::phase_3_run_analysis_passes::h3931958423828830349
  14:     0x7fab8ac8fded - driver::compile_input::h4f0a6e7bed616ea50ba
  15:     0x7fab8adf5d0b - run_compiler::ha3f4465c73f94406qqc
  16:     0x7fab8adf3576 - boxed::F.FnBox<A>::call_box::h9054381916092353385
  17:     0x7fab8adf2e84 - sys_common::unwind::try::try_fn::h18243607356614407688
  18:     0x7fab8a7ad538 - __rust_try
  19:     0x7fab8a7a1cd2 - sys_common::unwind::try::inner_try::h074d3cf1bfeda6e7Dbs
  20:     0x7fab8adf301e - boxed::F.FnBox<A>::call_box::h2812587830519910695
  21:     0x7fab8a7b5a03 - sys::thread::Thread::new::thread_start::h745044ae17db5a99dGw
  22:     0x7fab8474b4a3 - start_thread
  23:     0x7fab8a43d13c - clone
  24:                0x0 - <unknown>

However, the following works:

struct Test;

impl Test {
    pub extern fn test(val: &u8) {

    }
}

Rust version:

rustc 1.4.0-beta.1 (d2e13e822 2015-09-15)

Also tested on 1.3.0 stable. Haven't tested on nightly.

@dotdash
Copy link
Contributor

dotdash commented Sep 23, 2015

Probably the same problem as #28502

@dotdash dotdash added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 23, 2015
@mrhota
Copy link
Contributor

mrhota commented Mar 1, 2017

@steveklabnik this doesn't ICE any more. Tested on play: https://is.gd/3LyZdJ

@petrochenkov petrochenkov added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Mar 1, 2017
bors added a commit that referenced this issue Mar 6, 2017
Add missing tests for 'E-needstest' labeled issues

This PR adds missing tests for issue #35988, #19712, ~~#18627~~, #24947, #28600 and #34751.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

4 participants