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

Panic when using per-package-target #12839

Closed
Coder-256 opened this issue Oct 17, 2023 · 4 comments
Closed

Panic when using per-package-target #12839

Coder-256 opened this issue Oct 17, 2023 · 4 comments
Labels
C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. Z-build-std Nightly: build-std Z-per-package-target Nightly: per-package-target

Comments

@Coder-256
Copy link

Coder-256 commented Oct 17, 2023

Problem

I am trying to use per-package-target to compile one crate from my workspace into WebAssembly. I am getting the following crash:

$ RUST_BACKTRACE=full cargo build

...

thread 'main' panicked at src/cargo/core/compiler/unit_dependencies.rs:177:34:
no entry found for key
stack backtrace:
   0:        0x102bce9c4 - std::backtrace_rs::backtrace::libunwind::trace::h815672f5996c9e34
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x102bce9c4 - std::backtrace_rs::backtrace::trace_unsynchronized::h2e094b2d8c270437
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x102bce9c4 - std::sys_common::backtrace::_print_fmt::hae24b71afea95695
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x102bce9c4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6d4268b2ed62fb94
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x102bf3ad8 - core::fmt::rt::Argument::fmt::h835101b6de0df17f
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/rt.rs:138:9
   5:        0x102bf3ad8 - core::fmt::write::h5d55d44549819258
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/fmt/mod.rs:1094:21
   6:        0x102bc8ef4 - std::io::Write::write_fmt::hc515897f91abd6cf
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/io/mod.rs:1714:15
   7:        0x102bce804 - std::sys_common::backtrace::_print::h5844dab5cfa39fca
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x102bce804 - std::sys_common::backtrace::print::h2c300c1ebedfc73c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x102bd0450 - std::panicking::default_hook::{{closure}}::h0aa9be5c44269370
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:270:22
  10:        0x102bd017c - std::panicking::default_hook::h2c0ef097934ee9e6
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:290:9
  11:        0x102bd0998 - std::panicking::rust_panic_with_hook::h84c8637cb6e56008
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:707:13
  12:        0x102bd08a4 - std::panicking::begin_panic_handler::{{closure}}::h25482adda06c7b7f
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:599:13
  13:        0x102bcee50 - std::sys_common::backtrace::__rust_end_short_backtrace::h0c6f3beb22324a29
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x102bd0608 - rust_begin_unwind
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
  15:        0x102c63c48 - core::panicking::panic_fmt::h9072a0246ecafd14
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
  16:        0x102c63c14 - core::panicking::panic_display::h0fe2ac8b51ec4864
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:150:5
  17:        0x102c63c14 - core::panicking::panic_str::h74f5c8d70a577e7e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:134:5
  18:        0x102c63c14 - core::option::expect_failed::h596bc03570a96e73
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/option.rs:1988:5
  19:        0x1012b517c - core::option::Option<T>::expect::hc8172dad6913d0c6
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/option.rs:898:21
  20:        0x1012b517c - <std::collections::hash::map::HashMap<K,V,S> as core::ops::index::Index<&Q>>::index::hb71218c8bced2408
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/collections/hash/map.rs:1341:23
  21:        0x1015785a8 - cargo::core::compiler::unit_dependencies::attach_std_deps::h0c66d5cad903abbd
                               at /Users/jacobgreenfield/git/cargo/src/cargo/core/compiler/unit_dependencies.rs:177:34
  22:        0x1015778d0 - cargo::core::compiler::unit_dependencies::build_unit_dependencies::h3e86a0769525f72b
                               at /Users/jacobgreenfield/git/cargo/src/cargo/core/compiler/unit_dependencies.rs:133:9
  23:        0x1012af3c0 - cargo::ops::cargo_compile::create_bcx::h0ea36e4378361218
                               at /Users/jacobgreenfield/git/cargo/src/cargo/ops/cargo_compile/mod.rs:405:26
  24:        0x1012aca4c - cargo::ops::cargo_compile::compile_ws::h6c7f983cd31a1df6
                               at /Users/jacobgreenfield/git/cargo/src/cargo/ops/cargo_compile/mod.rs:151:15
  25:        0x1012ac9a8 - cargo::ops::cargo_compile::compile_with_exec::h4bbcc2a9af266737
                               at /Users/jacobgreenfield/git/cargo/src/cargo/ops/cargo_compile/mod.rs:141:5
  26:        0x1012ac8f4 - cargo::ops::cargo_compile::compile::h0573fdf8d7df7a91
                               at /Users/jacobgreenfield/git/cargo/src/cargo/ops/cargo_compile/mod.rs:128:5
  27:        0x100d87600 - cargo::commands::check::exec::h44240dae1b35c6e9
                               at /Users/jacobgreenfield/git/cargo/src/bin/cargo/commands/check.rs:56:5
  28:        0x100d53f64 - cargo::cli::Exec::exec::h3a05a69014310f16
                               at /Users/jacobgreenfield/git/cargo/src/bin/cargo/cli.rs:446:36
  29:        0x100d4f328 - cargo::cli::main::hd3d5652893557d43
                               at /Users/jacobgreenfield/git/cargo/src/bin/cargo/cli.rs:184:5
  30:        0x100d818ac - cargo::main::hf890cf6122991998
                               at /Users/jacobgreenfield/git/cargo/src/bin/cargo/main.rs:31:9
  31:        0x100d6eecc - core::ops::function::FnOnce::call_once::h85f91cf47639f35e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:250:5
  32:        0x100d0bc34 - std::sys_common::backtrace::__rust_begin_short_backtrace::h58a2daf855c87043
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:154:18
  33:        0x100d73878 - std::rt::lang_start::{{closure}}::heef3f5f19471e044
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:166:18
  34:        0x102bc0870 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h7fff7c88c61df16f
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:284:13
  35:        0x102bc0870 - std::panicking::try::do_call::h5c3526811781b4da
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
  36:        0x102bc0870 - std::panicking::try::h64cb573047f67390
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
  37:        0x102bc0870 - std::panic::catch_unwind::h0ee316aa6f14634c
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
  38:        0x102bc0870 - std::rt::lang_start_internal::{{closure}}::hbd896cc316ba7338
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:148:48
  39:        0x102bc0870 - std::panicking::try::do_call::hbae6886803fae47e
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
  40:        0x102bc0870 - std::panicking::try::hcc0fbb3995231d31
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
  41:        0x102bc0870 - std::panic::catch_unwind::hf36acbaf210582be
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
  42:        0x102bc0870 - std::rt::lang_start_internal::hadaf077a6dd0140b
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:148:20
  43:        0x100d73844 - std::rt::lang_start::h912fac66e698e029
                               at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:165:17
  44:        0x100d83e94 - _main

It appears to be crashing on this line (ie. std_roots does not contain unit.kind):

deps.extend(std_roots[&unit.kind].iter().map(|unit| UnitDep {

I put in a logging statement and confirmed that unit.kind is Target(CompileTarget { name: "wasm32-unknown-unknown" }).

Steps

  1. Set cargo-features = ["per-package-target"] and use forced-target = "wasm32-unknown-unknown"
  2. Run cargo build
  3. Cargo panics

Possible Solution(s)

Unknown

Notes

I can try to build an example repo if this is difficult to reproduce

Version

$ cargo version --verbose
cargo 1.75.0-nightly (794d0a825 2023-10-03)
release: 1.75.0-nightly
commit-hash: 794d0a82547f3081044c0aca7b6083733ce51344
commit-date: 2023-10-03
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.1.2 (sys:0.4.66+curl-8.3.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Mac OS 14.0.0 [64-bit]

I also tested using a local build of 8537dff (the backtrace comes from this version):

$ ../cargo/target/debug/cargo version --verbose
cargo 1.75.0 (8537dffa1 2023-10-17)
release: 1.75.0
commit-hash: 8537dffa1e4b74804e4af26cc4cb0c50e868df30
commit-date: 2023-10-17
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.1.2 (sys:0.4.68+curl-8.4.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 14.0.0 [64-bit]
@Coder-256 Coder-256 added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Oct 17, 2023
@weihanglo
Copy link
Member

Something related to #11898?

Having an example repo would be much appreciated!

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Oct 17, 2023
@Coder-256
Copy link
Author

Coder-256 commented Oct 17, 2023

Maybe, this could be a duplicate. I tried to make the code handle the missing key gracefully, but now I'm getting a different missing-key error, related to the alloc unit.

I'll try to set up a demo.

@Coder-256
Copy link
Author

Ok here's a reproducible example repo: https://github.com/Coder-256/per-package-crash

I do think this is likely related to #11898.

@weihanglo weihanglo added Z-build-std Nightly: build-std Z-per-package-target Nightly: per-package-target S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. and removed S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. labels Oct 18, 2023
@weihanglo
Copy link
Member

Thanks for making a repro for this issue! It's great to have a even simpler example.

Since it's a duplicate, I'll close this in favor of the old one #11898.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. Z-build-std Nightly: build-std Z-per-package-target Nightly: per-package-target
Projects
None yet
Development

No branches or pull requests

2 participants