Repository navigation
Description
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-gnudoes not work either. -
It also failed on
randand other packages. -
When
RUST_LOGis set todebug, 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-versionfrom 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 usingcargo 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
Activity
Mark-Simulacrum commentedon 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).
hanna-kruppe commentedon May 27, 2017
I can't reproduce with a custom built rustc from yesterday's master:
It also appears I can't reproduce with an old nightly (but a month newer than the version OP reported) I had lying around:
Edit: The xargo version installed is different too, v0.3.7 instead of v.0.3.5, but the versions of
dbghelp-sysandrustc_versionare the same.Mark-Simulacrum commentedon May 27, 2017
Going to close, then. If anyone can reproduce, let us know!
icylogic commentedon 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 duringcargo 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::ioto 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,You'd better delete
~\.cargo\registryso that cargo won't use cache.It's not about
xargo. I've triedcargo install ripgrepand got the same error.icylogic commentedon 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
rustcreports an ICE inrustc_metadata::creaderwhen loading a crate but it's not available for some reasons. The compiler unwraps anResultvalue and panics because it's anErr.@Mark-Simulacrum
luis-guilherme commentedon Aug 4, 2021
Have the same issue when using a Ramdrive as temp folder on windows 10 and using rustc 1.53.0
I do use ramdrive as temp to reduce the wear on SSDs
ChrisDenton commentedon Aug 4, 2021
The problem is not ramdrives exactly. It's just that some ramdrive drivers do not fully implement the kernel interface. This means some basic Windows API functions will fail. I have created a workaround for one of the issues caused by this but I don't know if it'll be accepted because it means you might see weird looking paths in the output. I am investigating other solutions too.
luis-guilherme commentedon Sep 6, 2021
In my case I'm using ImDisk's Ramdrive
ChrisDenton commentedon Sep 6, 2021
Yeah, that's the one that usually causes the issue. I know the Radeon ram disk works but the free version is limited to 4GB.