rust-lang / rust-lang/rustc_codegen_cranelift

Bevy dynamic-linking makes the program crash

Open
#1,530 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug O-windows
Dominant language
Rust
Stars
2.1k
Forks
157
Avg merge
1d 19h
Merged PRs (30d)
3

Description

Minimal reproducible example: https://github.com/GlennFolker/cranedrop

The dynamic_linking feature flag, which converts bevy and std into a dylib for compile-time speedup, completely fails when using the Cranelift codegen backend.

System information:

  • OS and arch: Windows 11, x64.
  • Rustc version: rustc 1.83.0-nightly (0609062a9 2024-09-13).
  • Contents of ~/.cargo/Config.toml:
    [unstable]
    codegen-backend = true
    
    [profile.dev]
    codegen-backend = "cranelift"
    incremental = true
    lto = "off"
    
    [profile.dev.package."*"]
    opt-level = 3
    
    [profile.release]
    codegen-units = 1
    incremental = false
    lto = "on"
    
    [target.x86_64-pc-windows-msvc]
    linker = "rust-lld.exe"
    rustflags = [
        "-Z", "share-generics=no",
        "-Z", "threads=0",
    ]
    

cargo run with multi_threading disabled made the program encounter a segfault:

error: process didn't exit successfully: `target\x86_64-pc-windows-msvc\debug\cranedrop.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

cargo run with multi_threading enabled made the program panic:

thread 'main' panicked at C:\Users\glenn\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_tasks-0.14.2\src\task_pool.rs:186:22:
Failed to spawn thread.: Os { code: 87, kind: InvalidInput, message: "The parameter is incorrect." }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\x86_64-pc-windows-msvc\debug\cranedrop.exe` (exit code: 0xe06d7363)

Contributor guide

No contributing guide indexed for this repository

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 the cranedrop minimal reproducible example and its ~/.cargo/Config.toml settings, using Rust nightly on Windows with dynamic_linking and the Cranelift backend. Compare runs with multi_threading disabled and enabled, then inspect the reported bevy_tasks-0.14.2/src/task_pool.rs:186 failure. Done means the program no longer segfaults or panics in either configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
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.