-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Description
Summary
Rust-generated ARM64EC static libraries cause crashes (0xc0000096 - privileged instruction) when statically linked into ARM64X DLLs and loaded by x64 processes on ARM64 Windows. The same scenario works correctly with MSVC-compiled ARM64EC static libraries.
Environment
- Rust version: rustc 1.88.0 (6b00bc3 2025-06-23)
- Platform: Windows 11 ARM64 (10.0.26100)
- Target:
arm64ec-pc-windows-msvc - Toolchain: Visual Studio 2022 17.11+ with ARM64/ARM64EC build tools
Steps to Reproduce
- Create a minimal Rust library with C FFI exports
- Build it as static library for both
aarch64-pc-windows-msvcandarm64ec-pc-windows-msvc - Link both static libraries into an ARM64X DLL using
/machine:arm64x - Load the DLL from an x64 process on ARM64 Windows
- Process crashes with 0xc0000096
Attached arm64x-rust-test.zip for minimal reproducible example
Expected Behavior
The ARM64X DLL should load successfully in x64 processes, with the ARM64EC code handling the x64 emulation layer properly, just as it does with MSVC-compiled ARM64EC static libraries.
Actual Behavior
x64 processes crash immediately upon loading the ARM64X DLL with error 0xc0000096 (privileged instruction).
Additional Context
- Works: Standalone ARM64EC DLL (not ARM64X) loads fine in x64 processes
- Works: ARM64X DLL without Rust (pure C++) loads fine in x64 processes
- Works: Same ARM64X DLL with Rust loads fine in ARM64 processes
- Fails: Only fails when x64 process loads ARM64X DLL containing Rust ARM64EC static lib
This suggests the issue is specific to the static library format and how the ARM64X linker processes Rust-generated ARM64EC objects.
Workarounds
- Build separate architecture-specific DLLs instead of ARM64X
- Use dynamic linking (Rust as separate DLL)
- Avoid Rust in ARM64X components
This issue affects any Windows on ARM application trying to use Rust in system components that must support both ARM64 and x64 processes (like Text Services Framework, shell extensions, COM servers, etc.).