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

Incorrect compilation / STATUS_ACCESS_VIOLATION when linking with lld with target-cpu set #72145

Closed
Systemcluster opened this issue May 12, 2020 · 18 comments · Fixed by #78041
Closed
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections O-windows-msvc Toolchain: MSVC, Operating system: Windows P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Systemcluster
Copy link

The compilation of crates fails in various ways when a certain combination of rustflags is set.

[build]
rustflags = [
	"-Clinker-flavor=lld-link",
	"-Ctarget-cpu=sandybridge"
]

With this configuration I encountered the following issues:

  • During installation of the sd crate (version 0.7.5), rustc crashes with a STATUS_ACCESS_VIOLATION. See the detailled error output below.
  • When installing starship, the resulting binary doesn't work correctly (see the issue here).

Using each rustflag individually does not result in this issue. I could reproduce this both on stable and the recent nightly, and with target-cpu set to either sandybridge, haswell or znver2 (without trying more).

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (99cb9ccb9 2020-05-11)
binary: rustc
commit-hash: 99cb9ccb9ca2067ad6e60508e3d52da77396b2f1
commit-date: 2020-05-11
host: x86_64-pc-windows-msvc
release: 1.45.0-nightly
LLVM version: 9.0
Error during cargo install --force sd

❯ cargo install --force sd
    Updating crates.io index
  Installing sd v0.7.5
   Compiling proc-macro2 v1.0.12
   Compiling autocfg v1.0.0
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.20
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Compiling version_check v0.9.1
   Compiling winapi v0.3.8
   Compiling getrandom v0.1.14
   Compiling maybe-uninit v2.0.0
   Compiling bitflags v1.2.1
   Compiling unicode-width v0.1.7
   Compiling libc v0.2.70
   Compiling unicode-segmentation v1.6.0
   Compiling scopeguard v1.1.0
   Compiling memchr v2.3.3
   Compiling vec_map v0.8.2
   Compiling strsim v0.8.0
   Compiling roff v0.1.0
   Compiling rayon-core v1.7.0
   Compiling ppv-lite86 v0.2.6
   Compiling either v1.5.3
   Compiling regex-syntax v0.6.17
   Compiling unescape v0.1.0
   Compiling thread_local v1.0.1
   Compiling textwrap v0.11.0
   Compiling man v0.3.0
   Compiling heck v0.3.1
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.4
   Compiling crossbeam-epoch v0.8.2
   Compiling rand_core v0.5.1
   Compiling proc-macro-error-attr v1.0.2
   Compiling proc-macro-error v1.0.2
   Compiling aho-corasick v0.7.10
   Compiling num_cpus v1.13.0
   Compiling rand_chacha v0.2.2
   Compiling quote v1.0.4
   Compiling rand v0.7.3
   Compiling crossbeam-queue v0.2.1
   Compiling crossbeam-deque v0.7.3
   Compiling rayon v1.3.0
   Compiling regex v1.3.7
   Compiling syn-mid v0.5.0
   Compiling atty v0.2.14
   Compiling remove_dir_all v0.5.2
   Compiling memmap v0.7.0
   Compiling clap v2.33.1
   Compiling tempfile v3.1.0
   Compiling thiserror-impl v1.0.16
   Compiling structopt-derive v0.4.7
   Compiling thiserror v1.0.16
   Compiling structopt v0.3.14
   Compiling sd v0.7.5
error: failed to compile `sd v0.7.5`, intermediate artifacts can be found at `C:\Users\Chris\AppData\Local\Temp\cargo-installLldcG5`

Caused by:
  could not compile `sd`.

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_build --edition=2018 C:\Users\Chris\.cargo\registry\src\github.com-1ecc6299db9ec823\sd-0.7.5\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C codegen-units=1 -C metadata=a9d539b504a5dcff -C extra-filename=-a9d539b504a5dcff --out-dir C:\Users\Chris\AppData\Local\Temp\cargo-installLldcG5\release\build\sd-a9d539b504a5dcff -L dependency=C:\Users\Chris\AppData\Local\Temp\cargo-installLldcG5\release\deps --extern man=C:\Users\Chris\AppData\Local\Temp\cargo-installLldcG5\release\deps\libman-415ee6d25251500d.rlib --extern structopt=C:\Users\Chris\AppData\Local\Temp\cargo-installLldcG5\release\deps\libstructopt-75fe88c87a7c5329.rlib --cap-lints allow -Clinker-flavor=lld-link -Ctarget-cpu=sandybridge` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Also possibly relevant for #71520.

@Systemcluster Systemcluster added the C-bug Category: This is a bug. label May 12, 2020
@jonas-schievink jonas-schievink added A-linkage Area: linking into static, shared libraries and binaries I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels May 12, 2020
@Systemcluster Systemcluster changed the title Incorrect compilation / STATUS_ACCESS_VIOLATION when when linking with lld with target-cpu set Incorrect compilation / STATUS_ACCESS_VIOLATION when linking with lld with target-cpu set May 12, 2020
@Systemcluster
Copy link
Author

I was able to reproduce the errors by specifying (in addition to linker-flavor) the target-features +fma or +avx instead of setting a target-cpu. Other target-features (e.g. +sse3,sse4.1) work fine as far as I can tell.

Possibly related to #64609?

@wesleywiser
Copy link
Member

Possibly related to #71504?

@Elinvynia Elinvynia added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 9, 2020
@spastorino spastorino added P-high High priority I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness I-nominated and removed I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 17, 2020
@spastorino
Copy link
Member

This was briefly mentioned during today's meeting
It may be good to figure out if this happens on lld on Linux:
@rustbot ping cleanup

or if it's just Windows thing:
@rustbot ping windows

Removing nomination also.

@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Jun 25, 2020
@spastorino
Copy link
Member

Second @rustbot ping didn't work ...

@rustbot ping windows

@LeSeulArtichaut

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2020

Hey Windows Group! This bug has been identified as a good "Windows candidate".
In case it's useful, here are some instructions for tackling these sorts of
bugs. Maybe take a look?
Thanks! <3

cc @arlosi @danielframpton @gdr-at-ms @kennykerr @luqmana @lzybkr @retep998 @rylev @sivadeilra @spastorino

@rustbot rustbot added the O-windows Operating system: Windows label Jun 25, 2020
@sivadeilra
Copy link

I spent some time trying to reproduce this, but wasn't able to. Can you provide more specific repro steps?

Alternately, can you run rustc.exe under WinDbg, and show the stack trace and u @rip at the faulting address?

What model CPU are you running on? Is it possible that the target features you're requesting are not available on that CPU?

@Systemcluster
Copy link
Author

Systemcluster commented Jun 26, 2020

@sivadeilra I'm using a AMD Ryzen 5 3600X, so at least -Ctarget-cpu=znver2 should be an exact match. AVX is definitely supported as well.

I can still reproduce the STATUS_ACCESS_VIOLATION with the current nightly during cargo install --force sd --version 0.7.5.

Here are the exact reproduction steps, with -Ctarget-feature=+avx to limit the features used:

  • Clean the registry to rule out interference with pre-existing caches:
    rm -r -Force ~/.cargo/registry

  • Install sd:
    cargo install --force sd --version 0.7.5

    Updating crates.io index
  Downloaded sd v0.7.5
  Downloaded 1 crate (14.8 KB) in 0.93s
  Installing sd v0.7.5
  Downloaded aho-corasick v0.7.13
  [...]
   Compiling structopt v0.3.15
   Compiling sd v0.7.5
error: failed to compile `sd v0.7.5`, intermediate artifacts can be found at `C:\Users\Chris\AppData\Local\Temp\cargo-install8LONA5`

Caused by:
  could not compile `sd`.

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_build --edition=2018 C:\Users\Chris\.cargo\registry\src\github.com-1ecc6299db9ec823\sd-0.7.5\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C codegen-units=1 -C metadata=d011dbc6f5f1cce2 -C extra-filename=-d011dbc6f5f1cce2 --out-dir C:\Users\Chris\AppData\Local\Temp\cargo-install8LONA5\release\build\sd-d011dbc6f5f1cce2 -L dependency=C:\Users\Chris\AppData\Local\Temp\cargo-install8LONA5\release\deps --extern man=C:\Users\Chris\AppData\Local\Temp\cargo-install8LONA5\release\deps\libman-b99848b80d918758.rlib --extern structopt=C:\Users\Chris\AppData\Local\Temp\cargo-install8LONA5\release\deps\libstructopt-ee882b02652d4990.rlib --cap-lints allow -Clinker-flavor=lld-link -Ctarget-feature=+avx` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

There's nothing more I did to reproduce it. However, just like with the broken starship installation, it seems somewhat sporadic - about 1 out of 10 times the compilation succeeds.

Meta:

rustc --version --verbose:

rustc 1.46.0-nightly (50fc24d8a 2020-06-25)
binary: rustc
commit-hash: 50fc24d8a172a853b5dfe40702d6550e3b8562ba
commit-date: 2020-06-25
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0

lld-link --version:

LLD 10.0.0

cat ~/.cargo/config:

[build]
rustflags = [
	"-Clinker-flavor=lld-link",
    "-Ctarget-feature=+avx"
]

I'm also using the latest Visual Studio Build Tools, if that's relevant.

I'll investigate with WinDbg later today and report back.

@mati865
Copy link
Contributor

mati865 commented Jun 26, 2020

Does not reproduce with windows-gnu on 2700X with:

[build]
rustflags = [
	"-Clink-arg=-fuse-ld=lld",
    "-Ctarget-feature=+avx"
]

LLVM 10 from MSYS2

@rustbot modify labels: -O-windows +O-windows-msvc

@rustbot rustbot added O-windows-msvc Toolchain: MSVC, Operating system: Windows and removed O-windows Operating system: Windows labels Jun 26, 2020
@Systemcluster
Copy link
Author

Systemcluster commented Jun 26, 2020

Also reproduces on a different system with a Intel i7-7820HQ for me with the same reproduction steps as above.

@sivadeilra Here is the WinDbg output and the stack trace. I used the rustc command specified in the cargo error log.

Command output
Microsoft (R) Windows Debugger Version 10.0.19528.1000 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: rustc  --crate-name build_script_build --edition=2018 C:\Users\Chris\.cargo\registry\src\github.com-1ecc6299db9ec823\sd-0.7.5\build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -Cembed-bitcode=no -C codegen-units=1 -C metadata=d011dbc6f5f1cce2 -C extra-filename=-d011dbc6f5f1cce2 --out-dir C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\build\sd-d011dbc6f5f1cce2 -L dependency=C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\deps --extern man=C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\deps\libman-b99848b80d918758.rlib --extern structopt=C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\deps\libstructopt-ee882b02652d4990.rlib --cap-lints allow -Clinker-flavor=lld-link -Ctarget-feature=+avx
Starting directory: C:\Users\Chris

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff7`02ce0000 00007ff7`03521000   rustup_init.exe
ModLoad: 00007ff9`406a0000 00007ff9`40890000   ntdll.dll
ModLoad: 00007ff9`3feb0000 00007ff9`3ff62000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ff9`3d990000 00007ff9`3dc34000   C:\WINDOWS\System32\KERNELBASE.dll

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff7`faf00000 00007ff7`fafe0000   conhost.exe
ModLoad: 00007ff9`406a0000 00007ff9`40890000   ntdll.dll
ModLoad: 00007ff9`3feb0000 00007ff9`3ff62000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ff9`3d990000 00007ff9`3dc34000   C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ff9`3d8f0000 00007ff9`3d98e000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ff9`3d7f0000 00007ff9`3d8ea000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ff9`3e7f0000 00007ff9`3e899000   C:\WINDOWS\System32\shcore.dll
ModLoad: 00007ff9`3e8a0000 00007ff9`3e93e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ff9`3f4c0000 00007ff9`3f5e0000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ff9`3f7b0000 00007ff9`3fae5000   C:\WINDOWS\System32\combase.dll
ModLoad: 00007ff9`3d690000 00007ff9`3d710000   C:\WINDOWS\System32\bcryptPrimitives.dll
ModLoad: 00007ff9`3edb0000 00007ff9`3ee53000   C:\WINDOWS\System32\advapi32.dll
ModLoad: 00007ff9`3e940000 00007ff9`3e9d7000   C:\WINDOWS\System32\sechost.dll
(36d0.2008): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`4077119c cc              int     3
1:001> g
ModLoad: 00007ff9`3faf0000 00007ff9`3fc84000   C:\WINDOWS\System32\user32.dll
ModLoad: 00007ff9`3dcb0000 00007ff9`3dcd1000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ff9`3e750000 00007ff9`3e776000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ff9`3de30000 00007ff9`3dfc5000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ff9`3ef90000 00007ff9`3efbe000   C:\WINDOWS\System32\IMM32.DLL
ModLoad: 00007ff9`3ff70000 00007ff9`40656000   C:\WINDOWS\System32\shell32.dll
ModLoad: 00007ff9`3dc40000 00007ff9`3dc8a000   C:\WINDOWS\System32\cfgmgr32.dll
ModLoad: 00007ff9`3dfd0000 00007ff9`3e750000   C:\WINDOWS\System32\windows.storage.dll
ModLoad: 00007ff9`3d5c0000 00007ff9`3d5e3000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ff9`3d570000 00007ff9`3d5ba000   C:\WINDOWS\System32\powrprof.dll
ModLoad: 00007ff9`3d560000 00007ff9`3d570000   C:\WINDOWS\System32\UMPDC.dll
ModLoad: 00007ff9`3ecc0000 00007ff9`3ed12000   C:\WINDOWS\System32\shlwapi.dll
ModLoad: 00007ff9`3d5f0000 00007ff9`3d601000   C:\WINDOWS\System32\kernel.appcore.dll
ModLoad: 00007ff9`3dc90000 00007ff9`3dca7000   C:\WINDOWS\System32\cryptsp.dll
ModLoad: 00007ff9`3b380000 00007ff9`3b419000   C:\WINDOWS\system32\uxtheme.dll
onecore\windows\core\console\open\src\interactivity\win32\systemconfigurationprovider.cpp(179)\conhost.exe!00007FF7FAF056B5: (caller: 00007FF7FAF060C3) LogHr(1) tid(2a94) 80004005 Unbekannter Fehler
onecore\windows\core\console\open\src\renderer\gdi\state.cpp(245)\conhost.exe!00007FF7FAF15477: (caller: 00007FF7FAF13FF7) LogHr(2) tid(5b4c) 80004005 Unbekannter Fehler
ModLoad: 00007ff9`3fc90000 00007ff9`3fdc5000   C:\WINDOWS\System32\MSCTF.dll
ModLoad: 00007ff9`3ee60000 00007ff9`3ef25000   C:\WINDOWS\System32\OLEAUT32.dll
ModLoad: 00007ff9`28fb0000 00007ff9`29234000   C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.900_none_e6beb9d913147d17\comctl32.DLL
ModLoad: 00007ff9`3b8e0000 00007ff9`3b90d000   C:\WINDOWS\SYSTEM32\dwmapi.dll
ModLoad: 00007ff9`2a7e0000 00007ff9`2a87e000   C:\WINDOWS\System32\TextInputFramework.dll
ModLoad: 00007ff9`37490000 00007ff9`377ba000   C:\WINDOWS\System32\CoreUIComponents.dll
ModLoad: 00007ff9`39d80000 00007ff9`39e54000   C:\WINDOWS\System32\CoreMessaging.dll
ModLoad: 00007ff9`3c580000 00007ff9`3c5b1000   C:\WINDOWS\SYSTEM32\ntmarta.dll
ModLoad: 00007ff9`3a230000 00007ff9`3a383000   C:\WINDOWS\SYSTEM32\wintypes.dll
ModLoad: 00000183`50180000 00000183`502d3000   C:\WINDOWS\SYSTEM32\wintypes.dll
ModLoad: 00000183`502e0000 00000183`50433000   C:\WINDOWS\SYSTEM32\wintypes.dll
ModLoad: 00007ff9`2db40000 00007ff9`2dde6000   C:\WINDOWS\System32\iertutil.dll
ModLoad: 00007ff9`3e9e0000 00007ff9`3ea82000   C:\WINDOWS\System32\clbcatq.dll
ModLoad: 00007ff9`3edb0000 00007ff9`3ee53000   C:\WINDOWS\System32\ADVAPI32.dll
ModLoad: 00007ff9`3e8a0000 00007ff9`3e93e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ff9`3e940000 00007ff9`3e9d7000   C:\WINDOWS\System32\sechost.dll
ModLoad: 00007ff9`3f4c0000 00007ff9`3f5e0000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ff9`3ea90000 00007ff9`3ebe7000   C:\WINDOWS\System32\ole32.dll
ModLoad: 00007ff9`3f7b0000 00007ff9`3fae5000   C:\WINDOWS\System32\combase.dll
ModLoad: 00007ff9`3d7f0000 00007ff9`3d8ea000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ff9`3d690000 00007ff9`3d710000   C:\WINDOWS\System32\bcryptPrimitives.dll
ModLoad: 00007ff9`3e750000 00007ff9`3e776000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ff9`3dcb0000 00007ff9`3dcd1000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ff9`3de30000 00007ff9`3dfc5000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ff9`3d8f0000 00007ff9`3d98e000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ff9`3faf0000 00007ff9`3fc84000   C:\WINDOWS\System32\USER32.dll
ModLoad: 00007ff9`3ee60000 00007ff9`3ef25000   C:\WINDOWS\System32\OLEAUT32.dll
ModLoad: 00007ff9`3ed30000 00007ff9`3ed9f000   C:\WINDOWS\System32\WS2_32.dll
ModLoad: 00007ff9`3dce0000 00007ff9`3de29000   C:\WINDOWS\System32\CRYPT32.dll
ModLoad: 00007ff9`3d610000 00007ff9`3d622000   C:\WINDOWS\System32\MSASN1.dll
ModLoad: 00007ff9`3ff70000 00007ff9`40656000   C:\WINDOWS\System32\SHELL32.dll
ModLoad: 00007ff9`3dc40000 00007ff9`3dc8a000   C:\WINDOWS\System32\cfgmgr32.dll
ModLoad: 00007ff9`2c260000 00007ff9`2c26c000   C:\WINDOWS\SYSTEM32\Secur32.dll
ModLoad: 00007ff9`3e7f0000 00007ff9`3e899000   C:\WINDOWS\System32\shcore.dll
ModLoad: 00007ff9`3dfd0000 00007ff9`3e750000   C:\WINDOWS\System32\windows.storage.dll
ModLoad: 00007ff9`3d5c0000 00007ff9`3d5e3000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ff9`3d570000 00007ff9`3d5ba000   C:\WINDOWS\System32\powrprof.dll
ModLoad: 00007ff9`3d560000 00007ff9`3d570000   C:\WINDOWS\System32\UMPDC.dll
ModLoad: 00007ff9`3ecc0000 00007ff9`3ed12000   C:\WINDOWS\System32\shlwapi.dll
ModLoad: 00007ff9`3d5f0000 00007ff9`3d601000   C:\WINDOWS\System32\kernel.appcore.dll
ModLoad: 00007ff9`3dc90000 00007ff9`3dca7000   C:\WINDOWS\System32\cryptsp.dll
ModLoad: 00007ff9`3d450000 00007ff9`3d475000   C:\WINDOWS\SYSTEM32\USERENV.dll
ModLoad: 00007ff9`3cf00000 00007ff9`3cf0c000   C:\WINDOWS\SYSTEM32\CRYPTBASE.DLL
ModLoad: 00007ff9`3d480000 00007ff9`3d4af000   C:\WINDOWS\SYSTEM32\SSPICLI.DLL
(66c.5e8c): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`4077119c cc              int     3
0:000> g
ModLoad: 00007ff9`3ef90000 00007ff9`3efbe000   C:\WINDOWS\System32\IMM32.DLL

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`75120000 00007ff6`7513b000   rustc_binary-cf2345702275a4fd.exe
ModLoad: 00007ff9`406a0000 00007ff9`40890000   ntdll.dll
ModLoad: 00007ff9`3feb0000 00007ff9`3ff62000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ff9`3d990000 00007ff9`3dc34000   C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ff8`ed8e0000 00007ff8`edbda000   C:\Users\Chris\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\std-36286308a8d35fa4.dll
ModLoad: 00007ff9`3edb0000 00007ff9`3ee53000   C:\WINDOWS\System32\ADVAPI32.dll
ModLoad: 00007ff8`a4b60000 00007ff8`aae2c000   C:\Users\Chris\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\rustc_driver-9cb24e1c020a8fb6.dll
ModLoad: 00007ff9`3eda0000 00007ff9`3eda8000   C:\WINDOWS\System32\PSAPI.DLL
ModLoad: 00007ff9`3e8a0000 00007ff9`3e93e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ff9`3ff70000 00007ff9`40656000   C:\WINDOWS\System32\SHELL32.dll
ModLoad: 00007ff9`3e940000 00007ff9`3e9d7000   C:\WINDOWS\System32\sechost.dll
ModLoad: 00007ff9`3d7f0000 00007ff9`3d8ea000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ff9`3f4c0000 00007ff9`3f5e0000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ff9`3dc40000 00007ff9`3dc8a000   C:\WINDOWS\System32\cfgmgr32.dll
ModLoad: 00007ff9`3ed30000 00007ff9`3ed9f000   C:\WINDOWS\System32\WS2_32.dll
ModLoad: 00007ff9`3e7f0000 00007ff9`3e899000   C:\WINDOWS\System32\shcore.dll
ModLoad: 00007ff9`3f7b0000 00007ff9`3fae5000   C:\WINDOWS\System32\combase.dll
ModLoad: 00007ff9`3d450000 00007ff9`3d475000   C:\WINDOWS\SYSTEM32\USERENV.dll
ModLoad: 00007ff9`3d690000 00007ff9`3d710000   C:\WINDOWS\System32\bcryptPrimitives.dll
ModLoad: 00007ff9`3d5c0000 00007ff9`3d5e3000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ff9`3dfd0000 00007ff9`3e750000   C:\WINDOWS\System32\windows.storage.dll
ModLoad: 00007ff9`3d8f0000 00007ff9`3d98e000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ff9`3cf00000 00007ff9`3cf0c000   C:\WINDOWS\SYSTEM32\CRYPTBASE.DLL
ModLoad: 00007ff9`3d570000 00007ff9`3d5ba000   C:\WINDOWS\System32\powrprof.dll
ModLoad: 00007ff9`3d560000 00007ff9`3d570000   C:\WINDOWS\System32\UMPDC.dll
ModLoad: 00007ff9`3ecc0000 00007ff9`3ed12000   C:\WINDOWS\System32\shlwapi.dll
ModLoad: 00007ff9`3e750000 00007ff9`3e776000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ff9`3dcb0000 00007ff9`3dcd1000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ff9`3de30000 00007ff9`3dfc5000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ff9`3faf0000 00007ff9`3fc84000   C:\WINDOWS\System32\USER32.dll
ModLoad: 00007ff9`3d5f0000 00007ff9`3d601000   C:\WINDOWS\System32\kernel.appcore.dll
ModLoad: 00007ff9`3dc90000 00007ff9`3dca7000   C:\WINDOWS\System32\cryptsp.dll
ModLoad: 00007ff9`3ea90000 00007ff9`3ebe7000   C:\WINDOWS\System32\ole32.dll
ModLoad: 00007ff9`3ee60000 00007ff9`3ef25000   C:\WINDOWS\System32\OLEAUT32.dll
(2430.6038): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`4077119c cc              int     3
2:011> g
ModLoad: 00007ff9`3ef90000 00007ff9`3efbe000   C:\WINDOWS\System32\IMM32.DLL
ModLoad: 00007ff8`eba80000 00007ff8`ebcae000   \\?\C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\deps\structopt_derive-9f1d169c48bf0bb3.dll
ModLoad: 00007ff9`2c240000 00007ff9`2c256000   C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll
(2430.5afc): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** WARNING: Unable to verify checksum for \\?\C:\Users\Chris\AppData\Local\Temp\cargo-installl0X1hR\release\deps\structopt_derive-9f1d169c48bf0bb3.dll
structopt_derive_9f1d169c48bf0bb3!_rust_realloc+0x3fe:
00007ff8`ebae654e c5fc288120000000 vmovaps ymm0,ymmword ptr [rcx+20h] ds:000002c8`178b5db0=00
2:015> u @rip
structopt_derive_9f1d169c48bf0bb3!_rust_realloc+0x3fe:
00007ff8`ebae654e c5fc288120000000 vmovaps ymm0,ymmword ptr [rcx+20h]
00007ff8`ebae6556 4883b92000000000 cmp     qword ptr [rcx+20h],0
00007ff8`ebae655e c5fc280d3af21100 vmovaps ymm1,ymmword ptr [structopt_derive_9f1d169c48bf0bb3!_ymm (00007ff8`ebc057a0)]
00007ff8`ebae6566 488b8130000000  mov     rax,qword ptr [rcx+30h]
00007ff8`ebae656d c5fc298920000000 vmovaps ymmword ptr [rcx+20h],ymm1
00007ff8`ebae6575 c5fc11442428    vmovups ymmword ptr [rsp+28h],ymm0
00007ff8`ebae657b c5f8288140000000 vmovaps xmm0,xmmword ptr [rcx+40h]
00007ff8`ebae6583 c5f811442448    vmovups xmmword ptr [rsp+48h],xmm0
2:015>
Stack trace
[0x0]   structopt_derive_9f1d169c48bf0bb3!_rust_realloc + 0x3fe   
[0x1]   structopt_derive_9f1d169c48bf0bb3!ZN16proc_macro_error5dummy9set_dummy17h1e5992d6979082c0E + 0xa4   
[0x2]   structopt_derive_9f1d169c48bf0bb3!ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17heb7072f126dc0b2bE + 0x29858   
[0x3]   structopt_derive_9f1d169c48bf0bb3!ZN244_$LT$std..error..$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$dyn$u20$std..error..Error$u2b$core..marker..Sync$u2b$core..marker..Send$GT$$GT$..from..StringError$u20$as$u20$core..fmt..Display$GT$3fmt17heb7072f126dc0b2bE + 0x2c386   
[0x4]   structopt_derive_9f1d169c48bf0bb3!ZN126_$LT$quote..__private..HasIterator$u20$as$u20$core..ops..bit..BitOr$LT$quote..__private..ThereIsNoIteratorInRepetition$GT$$GT$5bitor17h4d816340f770489aE + 0xffffffffffffad75   
[0x5]   structopt_derive_9f1d169c48bf0bb3!ZN126_$LT$quote..__private..HasIterator$u20$as$u20$core..ops..bit..BitOr$LT$quote..__private..ThereIsNoIteratorInRepetition$GT$$GT$5bitor17h4d816340f770489aE + 0xffffffffffffba3d   
[0x6]   rustc_driver_9cb24e1c020a8fb6!ZN77_$LT$rustc_expand..proc_macro_server..Literal$u20$as$u20$core..fmt..Debug$GT$3fmt17hf461a0b363b6ae6bE + 0x2b29   
[0x7]   rustc_driver_9cb24e1c020a8fb6!ZN99_$LT$rustc_expand..proc_macro..ProcMacroDerive$u20$as$u20$rustc_expand..base..MultiItemModifier$GT$6expand17h6af2be386c2379dcE + 0x218   
[0x8]   rustc_driver_9cb24e1c020a8fb6!ZN12rustc_expand6expand13MacroExpander21fully_expand_fragment17h94dfea398ba7337cE + 0xe23   
[0x9]   rustc_driver_9cb24e1c020a8fb6!ZN12rustc_expand6expand13MacroExpander12expand_crate17h922c621c04c28cdeE + 0x771   
[0xa]   rustc_driver_9cb24e1c020a8fb6!ZN95_$LT$rustc_interface..util..ReplaceBodyWithLoop$u20$as$u20$rustc_ast..mut_visit..MutVisitor$GT$9visit_mac17h9a215cc3c7eaed21E + 0x3d925   
[0xb]   rustc_driver_9cb24e1c020a8fb6!ZN15rustc_interface6passes13BoxedResolver19to_resolver_outputs17had819ccb417da138E + 0x7ff   
[0xc]   rustc_driver_9cb24e1c020a8fb6!ZN95_$LT$rustc_interface..util..ReplaceBodyWithLoop$u20$as$u20$rustc_ast..mut_visit..MutVisitor$GT$9visit_mac17h9a215cc3c7eaed21E + 0x5f6b7   
[0xd]   rustc_driver_9cb24e1c020a8fb6!ZN95_$LT$rustc_interface..util..ReplaceBodyWithLoop$u20$as$u20$rustc_ast..mut_visit..MutVisitor$GT$9visit_mac17h9a215cc3c7eaed21E + 0x4d876   
[0xe]   rustc_driver_9cb24e1c020a8fb6!ZN15rustc_interface7queries7Queries9expansion17hfa39941031a651e2E + 0x52a   
[0xf]   rustc_driver_9cb24e1c020a8fb6!ZN104_$LT$rustc_metadata..foreign_modules..Collector$u20$as$u20$rustc_hir..itemlikevisit..ItemLikeVisitor$GT$15visit_impl_item17hac3f9e9d30adf8a3E + 0x14e3ec   
[0x10]   rustc_driver_9cb24e1c020a8fb6!ZN62_$LT$rustc_driver..args..Error$u20$as$u20$core..fmt..Debug$GT$3fmt17h89937b97eaab9a16E + 0xf0e   
[0x11]   rustc_driver_9cb24e1c020a8fb6!ZN70_$LT$rustc_driver..DEFAULT_HOOK$u20$as$u20$core..ops..deref..Deref$GT$5deref17h8297b8690d51cce5E + 0x1412d   
[0x12]   rustc_driver_9cb24e1c020a8fb6!ZN52_$LT$i32$u20$as$u20$petgraph..matrix_graph..Zero$GT$4zero17hd68e191f7c98155bE + 0x1303   
[0x13]   std_36286308a8d35fa4!ZN3std3sys7windows6thread6Thread3new17h9c6ccf8206794202E + 0x1ca   
[0x14]   KERNEL32!BaseThreadInitThunk + 0x14   
[0x15]   ntdll!RtlUserThreadStart + 0x21   

Additionally the WinDbg output and the stack trace of running a miscompiled starship executable:

Command output
Microsoft (R) Windows Debugger Version 10.0.19528.1000 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: starship prompt
Starting directory: C:\Users\Chris

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`8c790000 00007ff6`8cc34000   starship-70f20c3ed1a6265e.exe
ModLoad: 00007ff9`406a0000 00007ff9`40890000   ntdll.dll
ModLoad: 00007ff9`3feb0000 00007ff9`3ff62000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ff9`3d990000 00007ff9`3dc34000   C:\WINDOWS\System32\KERNELBASE.dll

************* Path validation summary **************
Response                         Time (ms)     Location
Deferred                                       srv*
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff7`faf00000 00007ff7`fafe0000   conhost.exe
ModLoad: 00007ff9`406a0000 00007ff9`40890000   ntdll.dll
ModLoad: 00007ff9`3feb0000 00007ff9`3ff62000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ff9`3d990000 00007ff9`3dc34000   C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ff9`3d8f0000 00007ff9`3d98e000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ff9`3d7f0000 00007ff9`3d8ea000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ff9`3e7f0000 00007ff9`3e899000   C:\WINDOWS\System32\shcore.dll
ModLoad: 00007ff9`3e8a0000 00007ff9`3e93e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ff9`3f4c0000 00007ff9`3f5e0000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ff9`3f7b0000 00007ff9`3fae5000   C:\WINDOWS\System32\combase.dll
ModLoad: 00007ff9`3d690000 00007ff9`3d710000   C:\WINDOWS\System32\bcryptPrimitives.dll
ModLoad: 00007ff9`3edb0000 00007ff9`3ee53000   C:\WINDOWS\System32\advapi32.dll
ModLoad: 00007ff9`3e940000 00007ff9`3e9d7000   C:\WINDOWS\System32\sechost.dll
(6304.61e4): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`4077119c cc              int     3
1:001> g
ModLoad: 00007ff9`3faf0000 00007ff9`3fc84000   C:\WINDOWS\System32\user32.dll
ModLoad: 00007ff9`3dcb0000 00007ff9`3dcd1000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ff9`3e750000 00007ff9`3e776000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ff9`3de30000 00007ff9`3dfc5000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ff9`3ef90000 00007ff9`3efbe000   C:\WINDOWS\System32\IMM32.DLL
ModLoad: 00007ff9`3ff70000 00007ff9`40656000   C:\WINDOWS\System32\shell32.dll
ModLoad: 00007ff9`3dc40000 00007ff9`3dc8a000   C:\WINDOWS\System32\cfgmgr32.dll
ModLoad: 00007ff9`3dfd0000 00007ff9`3e750000   C:\WINDOWS\System32\windows.storage.dll
ModLoad: 00007ff9`3d5c0000 00007ff9`3d5e3000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ff9`3d570000 00007ff9`3d5ba000   C:\WINDOWS\System32\powrprof.dll
ModLoad: 00007ff9`3d560000 00007ff9`3d570000   C:\WINDOWS\System32\UMPDC.dll
ModLoad: 00007ff9`3ecc0000 00007ff9`3ed12000   C:\WINDOWS\System32\shlwapi.dll
ModLoad: 00007ff9`3d5f0000 00007ff9`3d601000   C:\WINDOWS\System32\kernel.appcore.dll
ModLoad: 00007ff9`3dc90000 00007ff9`3dca7000   C:\WINDOWS\System32\cryptsp.dll
ModLoad: 00007ff9`3b380000 00007ff9`3b419000   C:\WINDOWS\system32\uxtheme.dll
onecore\windows\core\console\open\src\interactivity\win32\systemconfigurationprovider.cpp(179)\conhost.exe!00007FF7FAF056B5: (caller: 00007FF7FAF060C3) LogHr(1) tid(62d8) 80004005 Unbekannter Fehler
onecore\windows\core\console\open\src\renderer\gdi\state.cpp(245)\conhost.exe!00007FF7FAF15477: (caller: 00007FF7FAF13FF7) LogHr(2) tid(52f8) 80004005 Unbekannter Fehler
ModLoad: 00007ff9`3fc90000 00007ff9`3fdc5000   C:\WINDOWS\System32\MSCTF.dll
ModLoad: 00007ff9`3ee60000 00007ff9`3ef25000   C:\WINDOWS\System32\OLEAUT32.dll
ModLoad: 00007ff9`28fb0000 00007ff9`29234000   C:\WINDOWS\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.900_none_e6beb9d913147d17\comctl32.DLL
ModLoad: 00007ff9`3b8e0000 00007ff9`3b90d000   C:\WINDOWS\SYSTEM32\dwmapi.dll
ModLoad: 00007ff9`2a7e0000 00007ff9`2a87e000   C:\WINDOWS\System32\TextInputFramework.dll
ModLoad: 00007ff9`39d80000 00007ff9`39e54000   C:\WINDOWS\System32\CoreMessaging.dll
ModLoad: 00007ff9`37490000 00007ff9`377ba000   C:\WINDOWS\System32\CoreUIComponents.dll
ModLoad: 00007ff9`3c580000 00007ff9`3c5b1000   C:\WINDOWS\SYSTEM32\ntmarta.dll
ModLoad: 00007ff9`3a230000 00007ff9`3a383000   C:\WINDOWS\SYSTEM32\wintypes.dll
ModLoad: 000001f0`9bac0000 000001f0`9bc13000   C:\WINDOWS\SYSTEM32\wintypes.dll
ModLoad: 00007ff9`2db40000 00007ff9`2dde6000   C:\WINDOWS\System32\iertutil.dll
ModLoad: 00007ff9`3e9e0000 00007ff9`3ea82000   C:\WINDOWS\System32\clbcatq.dll
ModLoad: 00007ff9`3ea90000 00007ff9`3ebe7000   C:\WINDOWS\System32\ole32.dll
ModLoad: 00007ff9`3f7b0000 00007ff9`3fae5000   C:\WINDOWS\System32\combase.dll
ModLoad: 00007ff9`3d7f0000 00007ff9`3d8ea000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ff9`3f4c0000 00007ff9`3f5e0000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ff9`3d690000 00007ff9`3d710000   C:\WINDOWS\System32\bcryptPrimitives.dll
ModLoad: 00007ff9`3edb0000 00007ff9`3ee53000   C:\WINDOWS\System32\advapi32.dll
ModLoad: 00007ff9`3e8a0000 00007ff9`3e93e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ff9`3e940000 00007ff9`3e9d7000   C:\WINDOWS\System32\sechost.dll
ModLoad: 00007ff9`3e750000 00007ff9`3e776000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ff9`3dcb0000 00007ff9`3dcd1000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ff9`3de30000 00007ff9`3dfc5000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ff9`3d8f0000 00007ff9`3d98e000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ff9`3faf0000 00007ff9`3fc84000   C:\WINDOWS\System32\USER32.dll
ModLoad: 00007ff9`3dce0000 00007ff9`3de29000   C:\WINDOWS\System32\CRYPT32.dll
ModLoad: 00007ff9`3d610000 00007ff9`3d622000   C:\WINDOWS\System32\MSASN1.dll
ModLoad: 00007ff9`3ee60000 00007ff9`3ef25000   C:\WINDOWS\System32\OLEAUT32.dll
ModLoad: 00007ff9`3d570000 00007ff9`3d5ba000   C:\WINDOWS\System32\POWRPROF.dll
ModLoad: 00007ff9`29270000 00007ff9`29287000   C:\WINDOWS\SYSTEM32\NETAPI32.dll
ModLoad: 00007ff9`3caa0000 00007ff9`3cada000   C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL
ModLoad: 00007ff9`3d560000 00007ff9`3d570000   C:\WINDOWS\System32\UMPDC.dll
ModLoad: 00007ff9`27e30000 00007ff9`27e78000   C:\WINDOWS\SYSTEM32\pdh.dll
ModLoad: 00007ff9`3eda0000 00007ff9`3eda8000   C:\WINDOWS\System32\PSAPI.DLL
ModLoad: 00007ff9`2c260000 00007ff9`2c26c000   C:\WINDOWS\SYSTEM32\Secur32.dll
ModLoad: 00007ff9`3f050000 00007ff9`3f4c0000   C:\WINDOWS\System32\SETUPAPI.dll
ModLoad: 00007ff9`3dc40000 00007ff9`3dc8a000   C:\WINDOWS\System32\cfgmgr32.dll
ModLoad: 00007ff9`3d710000 00007ff9`3d736000   C:\WINDOWS\System32\bcrypt.dll
ModLoad: 00007ff9`3ff70000 00007ff9`40656000   C:\WINDOWS\System32\SHELL32.dll
ModLoad: 00007ff9`3e7f0000 00007ff9`3e899000   C:\WINDOWS\System32\shcore.dll
ModLoad: 00007ff9`3dfd0000 00007ff9`3e750000   C:\WINDOWS\System32\windows.storage.dll
ModLoad: 00007ff9`3d5c0000 00007ff9`3d5e3000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ff9`3ecc0000 00007ff9`3ed12000   C:\WINDOWS\System32\shlwapi.dll
ModLoad: 00007ff9`3d5f0000 00007ff9`3d601000   C:\WINDOWS\System32\kernel.appcore.dll
ModLoad: 00007ff9`3dc90000 00007ff9`3dca7000   C:\WINDOWS\System32\cryptsp.dll
ModLoad: 00007ff9`3ed30000 00007ff9`3ed9f000   C:\WINDOWS\System32\WS2_32.dll
ModLoad: 00007ff9`2c240000 00007ff9`2c256000   C:\WINDOWS\SYSTEM32\VCRUNTIME140.dll
ModLoad: 00007ff9`3cf00000 00007ff9`3cf0c000   C:\WINDOWS\SYSTEM32\CRYPTBASE.DLL
ModLoad: 00007ff9`3cbb0000 00007ff9`3cbbc000   C:\WINDOWS\SYSTEM32\NETUTILS.DLL
ModLoad: 00007ff9`362f0000 00007ff9`36308000   C:\WINDOWS\SYSTEM32\SAMCLI.DLL
ModLoad: 00007ff9`3d480000 00007ff9`3d4af000   C:\WINDOWS\SYSTEM32\SSPICLI.DLL
(5cc4.5ddc): Break instruction exception - code 80000003 (first chance)
ntdll!LdrpDoDebuggerBreak+0x30:
00007ff9`4077119c cc              int     3
0:000> g
ModLoad: 00007ff9`3ef90000 00007ff9`3efbe000   C:\WINDOWS\System32\IMM32.DLL
(5cc4.5ddc): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** WARNING: Unable to verify checksum for starship-70f20c3ed1a6265e.exe
starship_70f20c3ed1a6265e!Ordinal0+0x185915:
00007ff6`8c915915 c5fc2888c0000000 vmovaps ymm1,ymmword ptr [rax+0C0h] ds:00000178`afaa49b0=00
0:000> u @rip
starship_70f20c3ed1a6265e!Ordinal0+0x185915:
00007ff6`8c915915 c5fc2888c0000000 vmovaps ymm1,ymmword ptr [rax+0C0h]
00007ff6`8c91591d 488bb0c0000000  mov     rsi,qword ptr [rax+0C0h]
00007ff6`8c915924 c5fc2980c0000000 vmovaps ymmword ptr [rax+0C0h],ymm0
00007ff6`8c91592c c5fc294b20      vmovaps ymmword ptr [rbx+20h],ymm1
00007ff6`8c915931 4885f6          test    rsi,rsi
00007ff6`8c915934 0f8493000000    je      starship_70f20c3ed1a6265e!Ordinal0+0x1859cd (00007ff6`8c9159cd)
00007ff6`8c91593a 488b05876c2f00  mov     rax,qword ptr [starship_70f20c3ed1a6265e!git_libgit2_opts+0x141918 (00007ff6`8cc0c5c8)]
00007ff6`8c915941 4883f801        cmp     rax,1
0:000>
Stack trace
[0x0]   starship_70f20c3ed1a6265e!Ordinal0 + 0x185915   
[0x1]   starship_70f20c3ed1a6265e!Ordinal0 + 0x2a62   
[0x2]   starship_70f20c3ed1a6265e!Ordinal0 + 0x26972   
[0x3]   starship_70f20c3ed1a6265e!Ordinal0 + 0x972fc   
[0x4]   starship_70f20c3ed1a6265e!Ordinal0 + 0xa5a62   
[0x5]   starship_70f20c3ed1a6265e!Ordinal0 + 0x227136   
[0x6]   starship_70f20c3ed1a6265e!Ordinal0 + 0xb9605   
[0x7]   starship_70f20c3ed1a6265e!git_libgit2_opts + 0x76c   
[0x8]   KERNEL32!BaseThreadInitThunk + 0x14   
[0x9]   ntdll!RtlUserThreadStart + 0x21   

@luqmana
Copy link
Member

luqmana commented Jun 26, 2020

Looks like it's reading a value from TLS and adding an offset to use as a pointer that is not 32-byte aligned (0x000002104d54ced0):

00007ffd`9ac9dfdb 8b0517321700         mov     eax, dword ptr [structopt_derive_afd65372c61b620b!_tls_index (00007ffd`9ae111f8)]
00007ffd`9ac9dfe1 65488b0c2558000000   mov     rcx, qword ptr gs:[58h]
00007ffd`9ac9dfea 488b0cc1             mov     rcx, qword ptr [rcx+rax*8]
00007ffd`9ac9dfee c5fc288120000000     vmovaps ymm0, ymmword ptr [rcx+20h] ds:00000210`4d54ced0=00
00007ffd`9ac9dff6 4883b92000000000     cmp     qword ptr [rcx+20h], 0
00007ffd`9ac9dffe c5fc280d5a051100     vmovaps ymm1, ymmword ptr [structopt_derive_afd65372c61b620b!_ymm (00007ffd`9adae560)]
00007ffd`9ac9e006 488b8130000000       mov     rax, qword ptr [rcx+30h]

This is happening in the proc_macro_error::dummy::set_dummy call which tries to read/write a thread local:

thread_local! {
    static DUMMY_IMPL: RefCell<Option<TokenStream>> = RefCell::new(None);
}

LLVM seems to believe it should be 32 byte aligned, but as far as I can tell when ntdll is allocating the TLS slots they're 16 byte aligned

@_ZN16proc_macro_error5dummy10DUMMY_IMPL7__getit5__KEY17h4a7e8c80e38ac6e5E = internal thread_local global <{ [64 x i8] }> zeroinitializer, align 32

Sounds like a similar issue to #44056

When built with lld-link there's no alignment specified for the TLS section in the DLL:

Dump of file structopt_derive-afd65372c61b620b.dll

File Type: DLL

  Section contains the following TLS directory:

    0000000180229000 Start of raw data
    0000000180229148 End of raw data
    00000001801E11F8 Address of index
    000000018019C3B0 Address of callbacks
                   0 Size of zero fill
            00000000 Characteristics
                       (no align specified)

But using the default msvc linker instead results in the correct alignment:

Dump of file structopt_derive-afd65372c61b620b.dll

File Type: DLL

  Section contains the following TLS directory:

    000000018019D960 Start of raw data
    000000018019DAA8 End of raw data
    00000001801E2278 Address of index
    000000018017D248 Address of callbacks
                   0 Size of zero fill
            00600000 Characteristics
                       32 byte align

Seems like an LLD bug?

@sivadeilra
Copy link

Ah, that's great that you've found what appears to be the root cause.

Are you / have you opened an issue for lld?

Is there more support needed from Windows devs?

@luqmana
Copy link
Member

luqmana commented Jun 26, 2020

I filed a bug: https://bugs.llvm.org/show_bug.cgi?id=46473

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 10, 2020
rustbuild: Build tests with LLD if `use-lld = true` was passed

Addresses rust-lang#76127 (comment).

Our test suite is generally ready to run with an explicitly specified linker (rust-lang#45191),
 so LLD specified with `use-lld = true` works as well.

Only 4 tests fail (on `x86_64-pc-windows-msvc`):
```
ui/panic-runtime/lto-unwind.rs
run-make-fulldeps/debug-assertions
run-make-fulldeps/foreign-exceptions
run-make-fulldeps/test-harness
```
All of them are legitimate issues with LLD (or at least with combination Rust+LLD) and manifest in segfaults on access to TLS (rust-lang#76127 (comment)). UPD: These issues are caused by rust-lang#72145 and appear because I had `-Ctarget-cpu=native` set.

UPD: Further commits build tests with LLD for non-MSVC targets and propagate LLD to more places when `use-lld` is enabled.
@luqmana
Copy link
Member

luqmana commented Oct 1, 2020

Finally got around to digging into LLD. Fix at https://reviews.llvm.org/D88637

@petrochenkov
Copy link
Contributor

petrochenkov commented Oct 1, 2020

@luqmana
I'm not sure, does this address the case of enabled AVX-512, where alignment should be even larger (64 byte instead of 32)?

@luqmana
Copy link
Member

luqmana commented Oct 1, 2020

@petrochenkov Yes, it does. When the loader (ntdll) encounters a module (exe/dll) using TLS, it looks up the TLS directory in the PE image and uses the alignment specified there for all TLS data in the module. So my patch just makes LLD save the max alignment of all .tls sections it encounters in the final binary.

So that means as long as you're annotating your thread_local's with the right alignment then it will work fine, i.e. using __m512 which is align(64).

In terms of allowed values, it's powers of 2 up to 8192 bytes with 16 as the default if unspecified.

@luqmana
Copy link
Member

luqmana commented Oct 15, 2020

Fix committed upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections O-windows-msvc Toolchain: MSVC, Operating system: Windows P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.