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

Random STATUS_ACCESS_VIOLATION on aarch64-pc-windows-msvc #118462

Closed
DervexDev opened this issue Nov 29, 2023 · 12 comments · Fixed by #118464
Closed

Random STATUS_ACCESS_VIOLATION on aarch64-pc-windows-msvc #118462

DervexDev opened this issue Nov 29, 2023 · 12 comments · Fixed by #118464
Assignees
Labels
C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-windows Operating system: Windows P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another.

Comments

@DervexDev
Copy link

Problem

Note

This issue only occurs on Windows ARM! (Tested on macOS Sonoma and Ubuntu ARM)

After using cargo build command random dependencies throw STATUS_ACCESS_VIOLATION error. I'm 100% sure that dependencies I'm trying to build are valid because at every compile attempt different dependency fails e.g. toml_edit, crossbeam-channel, actix-router.

Sometimes none of imported dependencies fail and out of 5 attempts I was able to build project succesfully twice (I deleted target folder after each attempt).

Example output:

   ...
   Compiling walkdir v2.4.0
   Compiling actix-router v0.5.1
   Compiling cookie v0.16.2
error: could not compile `actix-router` (lib)

Caused by:
  process didn't exit successfully: `rustc --crate-name actix_router --edition=2018 C:\Users\dervex\.cargo\registry\src\index.crates.io-6f17d22bba15001f\actix-router-0.5.1\src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=175 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg "feature=\"default\"" --cfg "feature=\"http\"" -C metadata=2b7cf52e726e9f7c -C extra-filename=-2b7cf52e726e9f7c --out-dir C:\Users\dervex\Desktop\argon\target\debug\deps -L dependency=C:\Users\dervex\Desktop\argon\target\debug\deps --extern bytestring=C:\Users\dervex\Desktop\argon\target\debug\deps\libbytestring-299f3658ce02b902.rmeta --extern http=C:\Users\dervex\Desktop\argon\target\debug\deps\libhttp-43d74e08691fef63.rmeta --extern regex=C:\Users\dervex\Desktop\argon\target\debug\deps\libregex-91e5fd69638fe8f5.rmeta --extern serde=C:\Users\dervex\Desktop\argon\target\debug\deps\libserde-752549031e501119.rmeta --extern tracing=C:\Users\dervex\Desktop\argon\target\debug\deps\libtracing-dacc595cf0b6c699.rmeta --cap-lints allow` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
warning: build failed, waiting for other jobs to finish...

Steps

  1. Add some dependencies (in my case 23)
  2. Use cargo build command

Possible Solution(s)

Improve build scripts on Windows ARM?

Notes

Important

I'm running virtualized Windows 11 using Parallels 19
Host Machine: M2 Pro Macbook
Host OS: macOS Sonoma

Version

cargo 1.74.0 (ecb9851af 2023-10-18)
release: 1.74.0
commit-hash: ecb9851afd3095e988daaa35a48bc7f3cb748e04
commit-date: 2023-10-18
host: aarch64-pc-windows-msvc
libgit2: 1.7.1 (sys:0.18.0 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:Schannel)
os: Windows 10.0.22621 (Windows 11 Professional) [64-bit]
@DervexDev DervexDev added the C-bug Category: This is a bug. label Nov 29, 2023
@ehuss ehuss changed the title Random STATUS_ACCESS_VIOLATION error when building package Random STATUS_ACCESS_VIOLATION on aarch64-pc-windows-msvc Nov 29, 2023
@ehuss ehuss transferred this issue from rust-lang/cargo Nov 29, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 29, 2023
@ehuss ehuss added O-windows Operating system: Windows O-AArch64 Armv8-A or later processors in AArch64 mode regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Nov 29, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Nov 29, 2023
@ehuss
Copy link
Contributor

ehuss commented Nov 29, 2023

Thanks for the report! Transferred to rust-lang/rust since this is a compiler issue.

I'm able to reproduce, though I am also using Parallels on an aarch64 mac. I do not have native Windows ARM hardware to test, so I'm not sure if this is unique to the M2 or Parallels. If someone has native hardware, it might be good to help with testing to see if it is a general problem with the target.

This appears to be a regression, and I have bisected to #115911. cc @nebulark @Nilstrieb

@wesleywiser
Copy link
Member

I'm seeing the same issue intermittently on a project that uses -Zstack-protector=strong. It looks like we might have a UAF on an LLVM object.

Crashing stack
0:004> k
 # Child-SP          RetAddr               Call Site
00 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::Metadata::getMetadataID [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Metadata.h @ 101] 
01 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::MDNode::classof [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Metadata.h @ 1313] 
02 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::isa_impl<llvm::MDNode,llvm::Metadata,void>::doit [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 64] 
03 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::isa_impl_cl<llvm::MDNode,llvm::Metadata const *>::doit+0x1c [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 110] 
04 000000d4`58cfe480 00007ff8`9b1a70f8     rustc_driver_398f9171fe0f6b1a!llvm::isa_impl_wrap<llvm::MDNode,llvm::Metadata const *,llvm::Metadata const *>::doit+0x25 [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 137] 
05 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::isa_impl_wrap<llvm::MDNode,llvm::Metadata * const,llvm::Metadata const *>::doit+0xf [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 127] 
06 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::CastIsPossible<llvm::MDNode,llvm::Metadata *,void>::isPossible+0xf [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 255] 
07 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::CastInfo<llvm::MDNode,llvm::Metadata *,void>::doCastIfPossible+0xf [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 493] 
08 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::dyn_cast+0x9e [D:\code\rust6\src\llvm-project\llvm\include\llvm\Support\Casting.h @ 663] 
09 000000d4`58cfe4b0 00007ff8`9b1b4076     rustc_driver_398f9171fe0f6b1a!llvm::ReplaceableMetadataImpl::getIfExists+0xa8 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Metadata.cpp @ 366] 
0a 000000d4`58cfe4e0 00007ff8`9ca1997b     rustc_driver_398f9171fe0f6b1a!llvm::MetadataTracking::untrack+0x36 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Metadata.cpp @ 169] 
0b (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::MetadataTracking::untrack+0x5 [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Metadata.h @ 247] 
0c (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::TrackingMDRef::untrack+0xd [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\TrackingMDRef.h @ 90] 
0d (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::TrackingMDRef::{dtor}+0xd [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\TrackingMDRef.h @ 55] 
0e (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::MachineIRBuilder::{dtor}+0xd [D:\code\rust6\src\llvm-project\llvm\include\llvm\CodeGen\GlobalISel\MachineIRBuilder.h @ 263] 
0f 000000d4`58cfe510 00007ff8`9b0d77a5     rustc_driver_398f9171fe0f6b1a!`anonymous namespace'::AArch64InstructionSelector::`scalar deleting destructor'+0x3b
10 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::default_delete<llvm::InstructionSelector>::operator()+0xa [C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.39.33218\include\memory @ 3170] 
11 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::unique_ptr<llvm::InstructionSelector,std::default_delete<llvm::InstructionSelector> >::{dtor}+0x16 [C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.39.33218\include\memory @ 3280] 
12 000000d4`58cfe540 00007ff8`9b0d76f7     rustc_driver_398f9171fe0f6b1a!llvm::AArch64Subtarget::~AArch64Subtarget+0x55
13 000000d4`58cfe570 00007ff8`9b0d795f     rustc_driver_398f9171fe0f6b1a!llvm::StringMap<std::unique_ptr<llvm::AArch64Subtarget,std::default_delete<llvm::AArch64Subtarget> >,llvm::MallocAllocator>::~StringMap<std::unique_ptr<llvm::AArch64Subtarget,std::default_delete<llvm::AArch64Subtarget> >,llvm::MallocAllocator>+0x67 [D:\code\rust6\src\llvm-project\llvm\include\llvm\ADT\StringMap.h @ 187] 
14 000000d4`58cfe5b0 00007ff8`9b0d7cf4     rustc_driver_398f9171fe0f6b1a!llvm::AArch64TargetMachine::~AArch64TargetMachine+0x1f [D:\code\rust6\src\llvm-project\llvm\lib\Target\AArch64\AArch64TargetMachine.cpp @ 382] 
15 000000d4`58cfe5e0 00007ff8`9b0801a6     rustc_driver_398f9171fe0f6b1a!llvm::AArch64leTargetMachine::`scalar deleting destructor'+0x14
16 000000d4`58cfe610 00007ff8`98a77e4d     rustc_driver_398f9171fe0f6b1a!LLVMRustDisposeTargetMachine+0xc6 [D:\code\rust6\compiler\rustc_llvm\llvm-wrapper\PassWrapper.cpp @ 534] 
17 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::back::owned_target_machine::impl$2::drop+0xd [D:\code\rust6\compiler\rustc_codegen_llvm\src\back\owned_target_machine.rs @ 100] 
18 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::ptr::drop_in_place+0xd [D:\code\rust6\library\core\src\ptr\mod.rs @ 497] 
19 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::ptr::drop_in_place+0x16 [D:\code\rust6\library\core\src\ptr\mod.rs @ 497] 
1a (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::ptr::drop_in_place+0x2d [D:\code\rust6\library\core\src\ptr\mod.rs @ 497] 
1b 000000d4`58cfe640 00007ff8`9898e42c     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>::into_compiled_module<rustc_codegen_llvm::ModuleLlvm>+0x15d [D:\code\rust6\compiler\rustc_codegen_ssa\src\lib.rs @ 86] 
1c 000000d4`58cfe730 00007ff8`98a340c7     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::back::write::codegen+0x1c0c [D:\code\rust6\compiler\rustc_codegen_llvm\src\back\write.rs @ 871] 
1d (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::impl$3::codegen+0x1f [D:\code\rust6\compiler\rustc_codegen_llvm\src\lib.rs @ 245] 
1e 000000d4`58cfea20 00007ff8`98a3466c     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::finish_intra_module_work<rustc_codegen_llvm::LlvmCodegenBackend>+0x177 [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 962] 
1f 000000d4`58cfed00 00007ff8`989442fe     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::execute_optimize_work_item<rustc_codegen_llvm::LlvmCodegenBackend>+0x40c [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 886] 
20 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::spawn_work::closure$0+0x514 [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 1752] 
21 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::impl$2::spawn_named_thread::closure$0+0x541 [D:\code\rust6\compiler\rustc_codegen_llvm\src\lib.rs @ 159] 
22 000000d4`58cff010 00007ff8`9894bddf     rustc_driver_398f9171fe0f6b1a!std::sys_common::backtrace::__rust_begin_short_backtrace<rustc_codegen_llvm::impl$2::spawn_named_thread::closure_env$0<rustc_codegen_ssa::back::write::spawn_work::closure_env$0<rustc_codegen_llvm::LlvmCodegenBackend>,tuple$<> >,tuple$<> >+0x56e [D:\code\rust6\library\std\src\sys_common\backtrace.rs @ 154] 
23 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::thread::impl$0::spawn_unchecked_::closure$1::closure$0+0xc [D:\code\rust6\library\std\src\thread\mod.rs @ 529] 
24 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::panic::unwind_safe::impl$23::call_once+0x3e [D:\code\rust6\library\core\src\panic\unwind_safe.rs @ 271] 
25 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panicking::try::do_call+0x3e [D:\code\rust6\library\std\src\panicking.rs @ 504] 
26 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panicking::try+0x3e [D:\code\rust6\library\std\src\panicking.rs @ 468] 
27 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panic::catch_unwind+0x3e [D:\code\rust6\library\std\src\panic.rs @ 142] 
28 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::thread::impl$0::spawn_unchecked_::closure$1+0x135 [D:\code\rust6\library\std\src\thread\mod.rs @ 528] 
29 000000d4`58cff490 00007ff8`b056650c     rustc_driver_398f9171fe0f6b1a!core::ops::function::FnOnce::call_once<std::thread::impl$0::spawn_unchecked_::closure_env$1<rustc_codegen_llvm::impl$2::spawn_named_thread::closure_env$0<rustc_codegen_ssa::back::write::spawn_work::closure_env$0<rustc_codegen_llvm::LlvmCodegenBackend>,tuple$<> >,tuple$<> >,tuple$<> >+0x16f [D:\code\rust6\library\core\src\ops\function.rs @ 250] 
2a 000000d4`58cff880 00007ff9`6adb257d     std_a52beccbc9d49308!ZN3std3sys7windows6thread6Thread3new17h7b02eb50d6b7b84eE+0x1bc
2b 000000d4`58cff910 00007ff9`6b86aa58     KERNEL32!BaseThreadInitThunk+0x1d [clientcore\base\win32\client\thread.c @ 75] 
2c 000000d4`58cff940 00000000`00000000     ntdll!RtlUserThreadStart+0x28 [minkernel\ntdll\rtlstrt.c @ 1166] 
Earlier "untrack" operation
0:004> k
 # Child-SP          RetAddr               Call Site
00 000000d4`58cfe2c0 00007ff8`9b1d3647     rustc_driver_398f9171fe0f6b1a!llvm::MetadataTracking::untrack+0x94 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Metadata.cpp @ 171] 
01 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::MetadataTracking::untrack+0x5 [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Metadata.h @ 247] 
02 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::TrackingMDRef::untrack+0x12 [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\TrackingMDRef.h @ 90] 
03 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::TrackingMDRef::{dtor}+0x12 [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\TrackingMDRef.h @ 55] 
04 000000d4`58cfe2f0 00007ff8`9b15c4cc     rustc_driver_398f9171fe0f6b1a!llvm::Instruction::~Instruction+0x67 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Instruction.cpp @ 64] 
05 000000d4`58cfe320 00007ff8`9b1dab59     rustc_driver_398f9171fe0f6b1a!llvm::Value::deleteValue+0x15c [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Instruction.def @ 220] 
06 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::ilist_alloc_traits<llvm::Instruction>::deleteNode+0x30 [D:\code\rust6\src\llvm-project\llvm\include\llvm\IR\Instruction.h @ 924] 
07 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>,llvm::SymbolTableListTraits<llvm::Instruction> >::erase+0x69 [D:\code\rust6\src\llvm-project\llvm\include\llvm\ADT\ilist.h @ 205] 
08 000000d4`58cfe350 00007ff8`9b1da71e     rustc_driver_398f9171fe0f6b1a!llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>,llvm::SymbolTableListTraits<llvm::Instruction> >::erase+0xa9 [D:\code\rust6\src\llvm-project\llvm\include\llvm\ADT\ilist.h @ 242] 
09 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>,llvm::SymbolTableListTraits<llvm::Instruction> >::clear+0x16 [D:\code\rust6\src\llvm-project\llvm\include\llvm\ADT\ilist.h @ 246] 
0a 000000d4`58cfe390 00007ff8`9b1dabf8     rustc_driver_398f9171fe0f6b1a!llvm::BasicBlock::~BasicBlock+0x15e [D:\code\rust6\src\llvm-project\llvm\lib\IR\BasicBlock.cpp @ 94] 
0b 000000d4`58cfe3c0 00007ff8`9b20718c     rustc_driver_398f9171fe0f6b1a!llvm::BasicBlock::eraseFromParent+0x38 [D:\code\rust6\src\llvm-project\llvm\lib\IR\BasicBlock.cpp @ 133] 
0c 000000d4`58cfe3f0 00007ff8`9b2463c0     rustc_driver_398f9171fe0f6b1a!llvm::Function::dropAllReferences+0xcc [D:\code\rust6\src\llvm-project\llvm\lib\IR\Function.cpp @ 536] 
0d 000000d4`58cfe420 00007ff8`9b24571f     rustc_driver_398f9171fe0f6b1a!llvm::Module::dropAllReferences+0x50 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Module.cpp @ 535] 
0e 000000d4`58cfe460 00007ff8`9b076874     rustc_driver_398f9171fe0f6b1a!llvm::Module::~Module+0x2f [D:\code\rust6\src\llvm-project\llvm\lib\IR\Module.cpp @ 81] 
0f 000000d4`58cfe4a0 00007ff8`9ba47187     rustc_driver_398f9171fe0f6b1a!llvm::Module::`scalar deleting destructor'+0x14
10 000000d4`58cfe4d0 00007ff8`9b1d0b76     rustc_driver_398f9171fe0f6b1a!llvm::LLVMContextImpl::~LLVMContextImpl+0x67 [D:\code\rust6\src\llvm-project\llvm\lib\IR\LLVMContextImpl.cpp @ 51] 
11 000000d4`58cfe5e0 00007ff8`9b065a32     rustc_driver_398f9171fe0f6b1a!llvm::LLVMContext::~LLVMContext+0x16 [D:\code\rust6\src\llvm-project\llvm\lib\IR\LLVMContext.cpp @ 113] 
12 000000d4`58cfe610 00007ff8`98a77e40     rustc_driver_398f9171fe0f6b1a!LLVMContextDispose+0x12 [D:\code\rust6\src\llvm-project\llvm\lib\IR\Core.cpp @ 128] 
13 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::impl$11::drop+0x9 [D:\code\rust6\compiler\rustc_codegen_llvm\src\lib.rs @ 460] 
14 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::ptr::drop_in_place+0x9 [D:\code\rust6\library\core\src\ptr\mod.rs @ 497] 
15 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::ptr::drop_in_place+0x20 [D:\code\rust6\library\core\src\ptr\mod.rs @ 497] 
16 000000d4`58cfe640 00007ff8`9898e42c     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>::into_compiled_module<rustc_codegen_llvm::ModuleLlvm>+0x150 [D:\code\rust6\compiler\rustc_codegen_ssa\src\lib.rs @ 86] 
17 000000d4`58cfe730 00007ff8`98a340c7     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::back::write::codegen+0x1c0c [D:\code\rust6\compiler\rustc_codegen_llvm\src\back\write.rs @ 871] 
18 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::impl$3::codegen+0x1f [D:\code\rust6\compiler\rustc_codegen_llvm\src\lib.rs @ 245] 
19 000000d4`58cfea20 00007ff8`98a3466c     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::finish_intra_module_work<rustc_codegen_llvm::LlvmCodegenBackend>+0x177 [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 962] 
1a 000000d4`58cfed00 00007ff8`989442fe     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::execute_optimize_work_item<rustc_codegen_llvm::LlvmCodegenBackend>+0x40c [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 886] 
1b (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_ssa::back::write::spawn_work::closure$0+0x514 [D:\code\rust6\compiler\rustc_codegen_ssa\src\back\write.rs @ 1752] 
1c (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!rustc_codegen_llvm::impl$2::spawn_named_thread::closure$0+0x541 [D:\code\rust6\compiler\rustc_codegen_llvm\src\lib.rs @ 159] 
1d 000000d4`58cff010 00007ff8`9894bddf     rustc_driver_398f9171fe0f6b1a!std::sys_common::backtrace::__rust_begin_short_backtrace<rustc_codegen_llvm::impl$2::spawn_named_thread::closure_env$0<rustc_codegen_ssa::back::write::spawn_work::closure_env$0<rustc_codegen_llvm::LlvmCodegenBackend>,tuple$<> >,tuple$<> >+0x56e [D:\code\rust6\library\std\src\sys_common\backtrace.rs @ 154] 
1e (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::thread::impl$0::spawn_unchecked_::closure$1::closure$0+0xc [D:\code\rust6\library\std\src\thread\mod.rs @ 529] 
1f (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!core::panic::unwind_safe::impl$23::call_once+0x3e [D:\code\rust6\library\core\src\panic\unwind_safe.rs @ 271] 
20 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panicking::try::do_call+0x3e [D:\code\rust6\library\std\src\panicking.rs @ 504] 
21 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panicking::try+0x3e [D:\code\rust6\library\std\src\panicking.rs @ 468] 
22 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::panic::catch_unwind+0x3e [D:\code\rust6\library\std\src\panic.rs @ 142] 
23 (Inline Function) --------`--------     rustc_driver_398f9171fe0f6b1a!std::thread::impl$0::spawn_unchecked_::closure$1+0x135 [D:\code\rust6\library\std\src\thread\mod.rs @ 528] 
24 000000d4`58cff490 00007ff8`b056650c     rustc_driver_398f9171fe0f6b1a!core::ops::function::FnOnce::call_once<std::thread::impl$0::spawn_unchecked_::closure_env$1<rustc_codegen_llvm::impl$2::spawn_named_thread::closure_env$0<rustc_codegen_ssa::back::write::spawn_work::closure_env$0<rustc_codegen_llvm::LlvmCodegenBackend>,tuple$<> >,tuple$<> >,tuple$<> >+0x16f [D:\code\rust6\library\core\src\ops\function.rs @ 250] 
25 000000d4`58cff880 00007ff9`6adb257d     std_a52beccbc9d49308!ZN3std3sys7windows6thread6Thread3new17h7b02eb50d6b7b84eE+0x1bc
26 000000d4`58cff910 00007ff9`6b86aa58     KERNEL32!BaseThreadInitThunk+0x1d [clientcore\base\win32\client\thread.c @ 75] 
27 000000d4`58cff940 00000000`00000000     ntdll!RtlUserThreadStart+0x28 [minkernel\ntdll\rtlstrt.c @ 1166] 

I'm guessing this might be triggered because #115911 causes us to drop the LLVM TargetMachine after dropping the LLVM context.

@wesleywiser
Copy link
Member

Swapping the drop order back to the way we had it originally makes my reproducer compile successfully.

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 30, 2023
@wesleywiser wesleywiser self-assigned this Nov 30, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 30, 2023
@bors bors closed this as completed in 640a431 Nov 30, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 30, 2023
Rollup merge of rust-lang#118464 - wesleywiser:fix_dispose_ordering, r=Nilstrieb

Dispose llvm::TargetMachines prior to llvm::Context being disposed

If the TargetMachine is disposed after the Context is disposed, it can lead to use after frees in some cases.

I've observed this happening occasionally on code compiled for aarch64-pc-windows-msvc using `-Zstack-protector=strong` but other users have reported AVs from host aarch64-pc-windows-msvc compilers as well.

I was not able to extract a self-contained test case yet so there is no accompanying test.

Fixes rust-lang#118462
@wesleywiser
Copy link
Member

Re-opening to track backports

@TitanNano
Copy link

I encountered this issue in Github CI yesterday. It only occurs with rust-1.74 but not with 1.73 and lower.

@apiraino
Copy link
Contributor

apiraino commented Dec 7, 2023

@TitanNano this should be fixed by #118464 and included in the upcoming 1.74.1 stable release. You can probably try a nightly rustc build if you're curious to test the fix.

@Noratrieb
Copy link
Member

1.74.1 has been released.

@TitanNano
Copy link

Yes 1.74.1 fixed it. 👍

@HoaPham98
Copy link

Hi, sorry for reply to the closed issue, but since I updated my M2 macbook to Sonoma 14.2 last week, I randomly got similar issue #119308

@chyyran
Copy link

chyyran commented Feb 20, 2024

This is happening again with aarch64-pc-windows-msvc

   Compiling tiff v0.9.1                                                                                                                                                                                                                                                                                                                                                                                                           
error: could not compile `num-traits` (lib)

Caused by:
  process didn't exit successfully: `rustc --crate-name num_traits --edition=2018 D:\Runtime\Rust\cargo\registry\src\index.crates.io-6f17d22bba15001f\num-traits-0.2.18\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=419 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg "feature=\"default\"" --cfg "feature=\"std\"" -C met
adata=30bc9611b16064ab -C extra-filename=-30bc9611b16064ab --out-dir F:\coding\librashader\target\aarch64-pc-windows-msvc\debug\deps --target aarch64-pc-windows-msvc -L dependency=F:\coding\librashader\target\aarch64-pc-windows-msvc\debug\deps -L dependency=F:\coding\librashader\target\debug\deps --cap-lints allow --cfg has_to_int_unchecked --cfg has_reverse_bits --cfg has_leading_trailing_ones --cfg has_div_euclid --cfg has_copysign --cfg has_is_subnormal --cfg has_total_cmp --cfg has_int_to_from_bytes --cfg has_float_to_from_bytes` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
warning: build failed, waiting for other jobs to finish...
    Building [============>            ] 100/192: ash, spirv-to-dxil-sys(build), glslang-sys(build), librashader-spirv-cross(build), windows, rspirv                  
    

Full log here https://github.com/SnowflakePowered/librashader/actions/runs/7981257472/job/21792707812

@Noratrieb
Copy link
Member

@chyyran
Please open a new issue, but it might also have something to do with #120511

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-AArch64 Armv8-A or later processors in AArch64 mode O-windows Operating system: Windows P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants