Skip to content

regression: duplicate symbol definition #137891

Closed as not planned
Closed as not planned

Description

@Mark-Simulacrum

https://crater-reports.s3.amazonaws.com/beta-1.86-3/beta-2025-02-28/gh/ns6251.spin-cookie-token-sample/log.txt

Possibly expected / not actually a problem, but probably good to figure out where this came from.

[INFO] [stdout]   = note: /usr/bin/ld: /opt/rustwide/target/debug/deps/libwit_bindgen_rust-7b7d20e188069fd3.rlib(wit_bindgen_rust-7b7d20e188069fd3.wit_bindgen_rust.712e9c6990f0d8a7-cgu.0.rcgu.o): in function `canonical_abi_realloc':
[INFO] [stdout]           /opt/rustwide/cargo-home/git/checkouts/wit-bindgen-e92a7091d4f51398/2f46ce4/crates/rust-wasm/src/lib.rs:134: multiple definition of `canonical_abi_realloc'; /opt/rustwide/target/debug/deps/libwit_bindgen_rust-742545eb826378e5.rlib(wit_bindgen_rust-742545eb826378e5.wit_bindgen_rust.ceb23070018b5742-cgu.0.rcgu.o):/opt/rustwide/cargo-home/git/checkouts/wit-bindgen-e92a7091d4f51398/e9c7c0a/crates/rust-wasm/src/lib.rs:134: first defined here
[INFO] [stdout]           /usr/bin/ld: /opt/rustwide/target/debug/deps/libwit_bindgen_rust-7b7d20e188069fd3.rlib(wit_bindgen_rust-7b7d20e188069fd3.wit_bindgen_rust.712e9c6990f0d8a7-cgu.0.rcgu.o): in function `canonical_abi_free':
[INFO] [stdout]           /opt/rustwide/cargo-home/git/checkouts/wit-bindgen-e92a7091d4f51398/2f46ce4/crates/rust-wasm/src/lib.rs:158: multiple definition of `canonical_abi_free'; /opt/rustwide/target/debug/deps/libwit_bindgen_rust-742545eb826378e5.rlib(wit_bindgen_rust-742545eb826378e5.wit_bindgen_rust.ceb23070018b5742-cgu.0.rcgu.o):/opt/rustwide/cargo-home/git/checkouts/wit-bindgen-e92a7091d4f51398/e9c7c0a/crates/rust-wasm/src/lib.rs:158: first defined here

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 2, 2025
  2. added this to the 1.86.0 milestone on Mar 2, 2025
  3. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 2, 2025
  4. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 2, 2025
  5. compiler-errors commented on Mar 2, 2025

    @compiler-errors
    Contributor

    This may have been #137035 -- @Mark-Simulacrum, does the beta you're triaging include that PR or not? Not sure how the timing worked out.

  6. saethlin commented on Mar 2, 2025

    @saethlin
    Member

    I got some weird results when trying to bisect this. Looks like the build still fails on nightly so I don't think that PR is it.

  7. Mark-Simulacrum commented on Mar 2, 2025

    @Mark-Simulacrum
    MemberAuthor

    Yeah, 137035 is included in beta (commit 42212a5 is what was tested here).

  8. apiraino commented on Mar 4, 2025

    @apiraino
    Contributor

    Assigning priority (discussion on Zulip).

    @rustbot label -I-prioritize +P-high

  9. added
    P-highHigh priority
    and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 4, 2025
  10. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 4, 2025
  11. saethlin commented on Mar 5, 2025

    @saethlin
    Member

    The crate in question uses a proc macro, and with that expanded, I can minimize the crate to this:

    use spin_sdk;
    
    #[export_name = "handle-http-request"]
    unsafe extern "C" fn __wit_bindgen_handle_http_request() {
        let layout = core::alloc::Layout::from_size_align_unchecked(1, 1);
        let result = std::alloc::alloc(layout);
        if result.is_null() {}
    
        wit_bindgen_rust::rt::as_i32(0);
        std::hint::black_box(RET_AREA);
    }
    static RET_AREA: u8 = 0;

    with

    [lib]
    crate-type = [ "cdylib" ]
    
    [dependencies]
    spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v0.3.0" }
    wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "e9c7c0a3405845cecd3fe06f3c20ab413302fc73" }

    Linkage minimizations are always trippy, so bear with me. We have a few layers to go.

  12. saethlin commented on Mar 5, 2025

    @saethlin
    Member

    Ah-ha! I tried a bunch of codegen-units settings and it looks like the reproducer is highly sensitive to the number of codegen-units used in building dependencies. That's probably why this error comes and goes sporadically.

  13. saethlin commented on Mar 5, 2025

    @saethlin
    Member

    Minimized a bit farther: (note that I turned spin-sdk into two of its transitive dependencies)

    use spin_sdk;
    
    #[export_name = "handle-http-request"]
    pub unsafe extern "C" fn __wit_bindgen_handle_http_request() {
        let layout = core::alloc::Layout::from_size_align_unchecked(1, 1);
        let result = std::alloc::alloc(layout);
        if result.is_null() {}
    
        wit_bindgen_rust::rt::as_i32(0);
    }
    [lib]
    crate-type = [ "cdylib" ]
    
    [dependencies]
    anyhow = "1" # required ???
    wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "e9c7c0a3405845cecd3fe06f3c20ab413302fc73" }
    spin-sdk = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "2f46ce4cc072107153da0cefe15bdc69aa5b84d0", package = "wit-bindgen-rust" }
  14. saethlin commented on Mar 5, 2025

    @saethlin
    Member

    The regressed crate is depending on multiple versions of wit-bindgen-rust, which has an rt module, which exports the canonical_abi_realloc and canonical_abi_free symbols.

    So the bigger question here is how does this crate ever build?

  15. saethlin commented on Mar 5, 2025

    @saethlin
    Member

    I'm going to close this because the crate in question is simply buggy. In an ideal world we would be issuing a warning for this kind of situation; this is now the second time I've root-caused a crater link error regression to a crate which is mistakenly depending on two versions of a library that exports an unmangled symbol.

  16. apiraino commented on Mar 5, 2025

    @apiraino
    Contributor

    wow thanks @saethlin for the deep dive 👍

    Should this crate be excluded from our crater runs?

    @rustbot label -P-high

  17. saethlin commented on Mar 5, 2025

    @saethlin
    Member
  18. added a commit that references this issue on Mar 6, 2025
  19. added a commit that references this issue on Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions