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

Bevy dynamic-linking makes the program crash #1530

Open
GlennFolker opened this issue Sep 14, 2024 · 4 comments
Open

Bevy dynamic-linking makes the program crash #1530

GlennFolker opened this issue Sep 14, 2024 · 4 comments
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows

Comments

@GlennFolker
Copy link

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)
@bjorn3
Copy link
Member

bjorn3 commented Sep 14, 2024

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

I don't use Windows, so I'm not sure I will be able to figure out what is going wrong. In any case could you please post a backtrace of the segfault?

cargo run with multi_threading enabled made the program panic:

This panic happens when trying to spawn a new thread. The error is not really informative about which parameter of the thread spawn function is incorrect.

@bjorn3 bjorn3 added C-bug Category: This is a bug. O-windows Operating system: Windows labels Sep 14, 2024
@GlennFolker
Copy link
Author

GlennFolker commented Sep 15, 2024

I tried yesterday, but I'm not sure how to GDB a Rust dynamically linked program since it complains about libbevy_dylib_<hash> and libstd_dylib_<hash> missing from the library path, and I just couldn't find them.

I'll try later today.

@GlennFolker
Copy link
Author

Well, I couldn't figure out a way to debug the builds, but apparently x86_64-pc-windows-gnu works just fine. Error only occurs on x86_64-pc-windows-msvc.

@bjorn3
Copy link
Member

bjorn3 commented Sep 15, 2024

I tried yesterday, but I'm not sure how to GDB a Rust dynamically linked program since it complains about libbevy_dylib_ and libstd_dylib_ missing from the library path, and I just couldn't find them.

You need to add both the full path to the target/x86_64-pc-windows-msvc/debug/deps dir and the path shown by rustc-clif --print target-libdir to your PATH before running the executable. Cargo and rustup together normally do this for you if you use cargo run. Also for MSVC you have to use windbg or similar as debugger. Gdb doesn't support reading debuginfo in the format MSVC uses (.pdb). Only the format unix systems use (DWARF).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

2 participants