rust-lang / rust-lang/cargo

Panic on curious [patch] combination

Open
#8,745 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-patch C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

$ cargo build
thread 'main' panicked at 'not currently active!?', src/tools/cargo/src/cargo/core/resolver/mod.rs:825:36
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fc2daaae610b5515438b551a2f3706196a997f35/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/fc2daaae610b5515438b551a2f3706196a997f35/library/core/src/panicking.rs:85
   2: core::option::expect_failed
             at /rustc/fc2daaae610b5515438b551a2f3706196a997f35/library/core/src/option.rs:1226
   3: cargo::core::resolver::activate_deps_loop
   4: cargo::core::resolver::resolve
   5: cargo::ops::resolve::resolve_with_previous
   6: cargo::ops::resolve::resolve_with_registry
   7: cargo::ops::resolve::resolve_ws_with_opts
   8: cargo::ops::cargo_compile::create_bcx
   9: cargo::ops::cargo_compile::compile_ws
  10: cargo::ops::cargo_compile::compile
  11: cargo::commands::build::exec
  12: cargo::cli::main
  13: cargo::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Steps

Try to build the following crate structure using Cargo.toml where ../wasmtime is a checkout of https://github.com/bytecodealliance/wasmtime.

# Cargo.toml
[package]
name = "headcrab"
version = "0.2.0"

[target.'cfg(target_os = "linux")'.dev-dependencies]
headcrab_inject = { path = "./headcrab_inject" }

[dev-dependencies]
rustc_codegen_cranelift = { path = "./cg_clif" }

[workspace]
exclude = ["./cg_clif"]

[patch.crates-io]
"cranelift-codegen" = { git = 'https://github.com/bytecodealliance/wasmtime/', branch = "main" }

[patch."https://github.com/bytecodealliance/wasmtime/"]
cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
# headcrab_inject/Cargo.toml
[package]
name = "headcrab_inject"
version = "0.2.0"

[dependencies]
headcrab = { version = "0.2.0", path = "../" }
cranelift-codegen = "0.67.0"
# cg_clif/Cargo.toml
[package]
name = "rustc_codegen_cranelift"
version = "0.1.0"

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] }

Notes

Output of cargo version: cargo 1.48.0-nightly (05c611ae3 2020-09-23)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/tools/cargo/src/cargo/core/resolver/mod.rs at line 825 and reproduce the panic using the three Cargo.toml files and cargo build described in the issue. Trace the resolver path from activate_deps_loop and verify that the reported crate combination completes without panicking; the issue provides no named regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.