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 on Windows: "incorrect function" #40282

Closed
icylogic opened this Issue Mar 5, 2017 · 5 comments

Comments

Projects
None yet
3 participants
@icylogic
Copy link

icylogic commented Mar 5, 2017

It happens when I try to install xargo via cargo install xargo, but it's an internel compiler error so I think it should be reported here. I've searched for the error message "incorrect function", but there is no relevant issue. (#31178 seems to be related to VirtualBox)

Logs (with RUST_BACKTRACE=full)

If I run this command multiple times, the panic happens randomly on different packages.

Failed on dbghelp-sys

D:\Temp\empty_dir>cargo install xargo
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing xargo v0.3.5
   Compiling winapi-build v0.1.1
   Compiling gcc v0.3.43
   Compiling libc v0.2.21
   Compiling xargo v0.3.5
   Compiling backtrace v0.3.0
   Compiling dbghelp-sys v0.2.0
   Compiling dtoa v0.2.2
error: internal compiler error: unexpected panic

   Compiling semver v0.1.20
note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 1, message: "Incorrect function." } }', src\libcore\result.rs:860
stack backtrace:
   0:     0x7ff869012a1f - <std::time::SystemTimeError as core::fmt::Display>::fmt::h4979473f9576d1ed
   1:     0x7ff869024bcc - std::panicking::Location::line::h170804a3d9d5008a
   2:     0x7ff86902440d - std::panicking::Location::line::h170804a3d9d5008a
   3:     0x7ff8690250f1 - std::panicking::rust_panic_with_hook::h616f04586b77efa9
   4:     0x7ff869024fa8 - std::panicking::begin_panic_fmt::h028887a0b806a12e
   5:     0x7ff869024ec4 - std::panicking::begin_panic_fmt::h028887a0b806a12e
   6:     0x7ff869024e59 - rust_begin_unwind
   7:     0x7ff8690372e7 - core::panicking::panic_fmt::h9303d733b4241e2b
   8:     0x7ff874292568 - <unknown>
   9:     0x7ff87433f0af - rustc_metadata::locator::Context::report_errs::hda477d168a30f72f
  10:     0x7ff87432c071 - rustc_metadata::creader::CrateLoader::new::h7bf5da15849ecfc2
  11:     0x7ff87432a628 - rustc_metadata::creader::CrateLoader::new::h7bf5da15849ecfc2
  12:     0x7ff874333f26 - <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_item::h258b2b401f5a9188
  13:     0x7ff87e256c7e - rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::Span, syntax::ext::hygiene::Mark)>::to_name_binding::hf7964fb6f9d14b15
  14:     0x7ff87e25e5b3 - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h70066d7c3e0a55b2
  15:     0x7ff87e25e80e - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h70066d7c3e0a55b2
  16:     0x7ff87e24e68f - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::h529069ee8f38fea8
  17:     0x7ff85cfb400f - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  18:     0x7ff85cfad460 - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  19:     0x7ff85cfaccaa - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  20:     0x7ff879b6675f - rustc_driver::driver::count_nodes::h6cb58d80fe92ca42
  21:     0x7ff879b5af72 - rustc_driver::driver::count_nodes::h6cb58d80fe92ca42
  22:     0x7ff879b51e36 - rustc_driver::driver::compile_input::ha02e227e35183dfd
  23:     0x7ff879bb3cd8 - rustc_driver::run_compiler::h4601882a3e07ab36
  24:     0x7ff879aa9e5e - <unknown>
  25:     0x7ff869028261 - _rust_maybe_catch_panic
  26:     0x7ff879acb2b6 - <unknown>
  27:     0x7ff86902244e - std::sys::imp::thread::Thread::new::hf457da10939bdcb7
  28:     0x7ff8a5358363 - BaseThreadInitThunk

error: Could not compile `dbghelp-sys`.
Build failed, waiting for other jobs to finish...
error: failed to compile `xargo v0.3.5`, intermediate artifacts can be found at `R:\Temp\cargo-install.qv3ogdZnww8r`

Caused by:
  build failed

Failed on rustc_version

D:\Temp\empty_dir>cargo install xargo
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing xargo v0.3.5
   Compiling backtrace v0.3.0
   Compiling rustc-serialize v0.3.22
   Compiling itoa v0.1.1
   Compiling serde v0.8.23
   Compiling rustc-demangle v0.1.4
   Compiling semver v0.1.20
   Compiling num-traits v0.1.37
   Compiling rustc_version v0.1.7
   Compiling winapi v0.2.8
error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 1, message: "Incorrect function." } }', src\libcore\result.rs:860
stack backtrace:
   0:     0x7ff869012a1f - <std::time::SystemTimeError as core::fmt::Display>::fmt::h4979473f9576d1ed
   1:     0x7ff869024bcc - std::panicking::Location::line::h170804a3d9d5008a
   2:     0x7ff86902440d - std::panicking::Location::line::h170804a3d9d5008a
   3:     0x7ff8690250f1 - std::panicking::rust_panic_with_hook::h616f04586b77efa9
   4:     0x7ff869024fa8 - std::panicking::begin_panic_fmt::h028887a0b806a12e
   5:     0x7ff869024ec4 - std::panicking::begin_panic_fmt::h028887a0b806a12e
   6:     0x7ff869024e59 - rust_begin_unwind
   7:     0x7ff8690372e7 - core::panicking::panic_fmt::h9303d733b4241e2b
   8:     0x7ff868c12568 - <unknown>
   9:     0x7ff868cbf0af - rustc_metadata::locator::Context::report_errs::hda477d168a30f72f
  10:     0x7ff868cac071 - rustc_metadata::creader::CrateLoader::new::h7bf5da15849ecfc2
  11:     0x7ff868caa628 - rustc_metadata::creader::CrateLoader::new::h7bf5da15849ecfc2
  12:     0x7ff868cb3f26 - <rustc_metadata::creader::CrateLoader<'a> as rustc::middle::cstore::CrateLoader>::process_item::h258b2b401f5a9188
  13:     0x7ff87e0c6c7e - rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::Span, syntax::ext::hygiene::Mark)>::to_name_binding::hf7964fb6f9d14b15
  14:     0x7ff87e0ce5b3 - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h70066d7c3e0a55b2
  15:     0x7ff87e0ce80e - <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor<'a, 'b> as syntax::visit::Visitor<'a>>::visit_item::h70066d7c3e0a55b2
  16:     0x7ff87e0be68f - rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::visit_expansion::h529069ee8f38fea8
  17:     0x7ff863b1400f - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  18:     0x7ff863b0d460 - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  19:     0x7ff863b0ccaa - syntax::ext::expand::MacroExpander::expand_crate::h9c2ada897f8517ae
  20:     0x7ff8742b675f - rustc_driver::driver::count_nodes::h6cb58d80fe92ca42
  21:     0x7ff8742aaf72 - rustc_driver::driver::count_nodes::h6cb58d80fe92ca42
  22:     0x7ff8742a1e36 - rustc_driver::driver::compile_input::ha02e227e35183dfd
  23:     0x7ff874303cd8 - rustc_driver::run_compiler::h4601882a3e07ab36
  24:     0x7ff8741f9e5e - <unknown>
  25:     0x7ff869028261 - _rust_maybe_catch_panic
  26:     0x7ff87421b2b6 - <unknown>
  27:     0x7ff86902244e - std::sys::imp::thread::Thread::new::hf457da10939bdcb7
  28:     0x7ff8a5358363 - BaseThreadInitThunk

error: Could not compile `rustc_version`.
Build failed, waiting for other jobs to finish...
error: failed to compile `xargo v0.3.5`, intermediate artifacts can be found at `R:\Temp\cargo-install.udJV5z3WDfuT`

Caused by:
  build failed

Details

  • rustc version:

    rustc 1.17.0-nightly (691eba135 2017-03-01)
    binary: rustc
    commit-hash: 691eba1358fc3c9c7a8033314a4112d43680c128
    commit-date: 2017-03-01 
    host: x86_64-pc-windows-msvc
    release: 1.17.0-nightly
    LLVM version: 3.9
    
  • The toolchain stable-x86_64-pc-windows-msvc (rustc 1.15.1), nightly-x86_64-pc-windows-gnu does not work either.

  • It also failed on rand and other packages.

  • When RUST_LOG is set to debug, the output has 618563 lines and i could not found any helpful information different from the backtrace.

  • I've tried a different binary package from Cargo like gcc and it is installed without problem.

  • I've also managed to clone rustc-version from the repo (https://github.com/Kimundi/rustc-version-rs/tree/v0.1.7) and dbghelp-sys from the repo (https://github.com/retep998/winapi-rs) and build them using cargo build, cargo build --release.

  • The command runs successfully on Linux

    rustc 1.17.0-nightly (691eba135 2017-03-01)
    binary: rustc
    commit-hash: 691eba1358fc3c9c7a8033314a4112d43680c128
    commit-date: 2017-03-01
    host: x86_64-unknown-linux-gnu
    release: 1.17.0-nightly
    LLVM version: 3.9
    
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 27, 2017

If someone on Windows could attempt to reproduce today, that'd be nice. Especially if they could get a backtrace with source lines (building from rustc src should work, but uncertain due to Windows).

@rkruppe

This comment has been minimized.

Copy link
Member

rkruppe commented May 27, 2017

I can't reproduce with a custom built rustc from yesterday's master:

rustc 1.19.0-dev (557967766 2017-05-26)
binary: rustc
commit-hash: 557967766be6139bd747ab2c3dc56ff0c9b8852a
commit-date: 2017-05-26
host: x86_64-pc-windows-msvc
release: 1.19.0-dev
LLVM version: 4.0

It also appears I can't reproduce with an old nightly (but a month newer than the version OP reported) I had lying around:

rustc 1.17.0-nightly (ccce2c6eb 2017-03-27)
binary: rustc
commit-hash: ccce2c6eb914a66571f60fa0afe8a46faa9fb3bd
commit-date: 2017-03-27
host: x86_64-pc-windows-msvc
release: 1.17.0-nightly
LLVM version: 3.9

Edit: The xargo version installed is different too, v0.3.7 instead of v.0.3.5, but the versions of dbghelp-sys and rustc_version are the same.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented May 27, 2017

Going to close, then. If anyone can reproduce, let us know!

@icylogic

This comment has been minimized.

Copy link
Author

icylogic commented Sep 17, 2017

Hi all. I finally found the problem and solved it. And I think it might be related to other issues, so I put information here although it's closed.

The "Incorrect function" is an error code from Win32 (MSDN), and its might be "used in generic device access error" (source).

My case is that the %TEMP% is set to a folder on a Ramdisk where rustc/cargo would save some intermediate files during building (something like cargo-install.4WWOdwfaa70N). Then this ICE would happen during cargo install some-binary-package. After I changed my temp dir to a local disk, the error disappeared.

But it's not only about Ramdisk, I've found these unsolved issues (#43801 #31178) have the same ICE on VirtualBox shared folders and network drives.

So it's actually an issue about IO operations on some "special" devices on Windows. Since I have not digged into the source code of cargo/rustc, I can't tell whether it's an issue for rustc, VirtualBox, Ramdisk and network drives or Win32 API.
But at least rustc/cargo could provide a more friendly message to notify users instead of an ICE with two words that almost no one could understand.

This error could not be reproduced if you just use std::io to write some bytes in the same path. It seems that this error happens when multiple IO operations are performing simultaneously "leading to fun race conditions" (from this comment)

Finally, if you are interested in this specific issue, here's how to reproduce it:

  • Mount a ramdisk using Imdisk driver , Imdisk-toolkit or some similar software.

  • Assuming it has a drive letter T,

    mkdir T:\temp
    set tmp=T:\temp
    set temp=T:\temp
    cargo install xargo
    
  • You'd better delete ~\.cargo\registry so that cargo won't use cache.

  • It's not about xargo. I've tried cargo install ripgrep and got the same error.

@icylogic

This comment has been minimized.

Copy link
Author

icylogic commented Sep 18, 2017

Found a similar issue #43215, although it's not "incorrect function" but "Access is denied.".

The common problem of these issues (#31178, #43215 and #40282) is that rustc reports an ICE in rustc_metadata::creader when loading a crate but it's not available for some reasons. The compiler unwraps an Result value and panics because it's an Err.

@Mark-Simulacrum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.