Repository: rust
Issue: rustc segfaults when loading mimalloc with LD_PRELOAD
Labels: I-crash,T-compiler,C-bug

Running https://github.com/shinchiro/mpv-winbuild-cmake/blob/master/toolchain/rustup.cmake on newly installed Arch Linux

```rust
    CONFIGURE_COMMAND ${EXEC} CONF=1
        curl -sSf https://sh.rustup.rs |
        sh -s -- -y --default-toolchain stable --target x86_64-pc-windows-gnu,i686-pc-windows-gnu --no-modify-path --profile minimal
    BUILD_COMMAND ${EXEC} rustup update
    INSTALL_COMMAND ${EXEC} cargo install cargo-c --profile=release-strip --features=vendored-openssl
```

Before June 8th, the install would succeed.

After June 8th, I got `error: rustc interrupted by SIGSEGV`

### Meta
The problem also happens in the nightly version. When I found the problem in nightly, tried it on stable and got the same problem.

```
stable-x86_64-unknown-linux-gnu installed - rustc 1.78.0 (9b00956e5 2024-04-29)
```
You can find the full log here:

https://raw.githubusercontent.com/CharlesMengCA/mpv-player-only/master/rustup-install-err.log

Hope someone can find the a solution for me. Thanks a lot!

<details><summary>Backtrace</summary>
<p>

```
  Downloaded openssl-src v300.3.1+3.3.1
   Compiling libc v0.2.155
   Compiling proc-macro2 v1.0.85
   Compiling unicode-ident v1.0.12
   Compiling cfg-if v1.0.0
   Compiling once_cell v1.19.0
   Compiling pkg-config v0.3.30
   Compiling vcpkg v0.2.15
   Compiling memchr v2.7.2
error: rustc interrupted by SIGSEGV, printing backtrace

/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x2e40fd3)[0x75bfb7840fd3]
/usr/lib/libc.so.6(+0x3cae0)[0x75bfb4850ae0]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x23a9e)[0x5f807b45ca9e]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc(+0x1c427)[0x5f807b455427]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm3sys22DontRemoveFileOnSignalENS_9StringRefE+0x1b2)[0x75bfb31f0a0e]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm3sys2fs8TempFile4keepERKNS_5TwineE+0x4c)[0x75bfb31f114c]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libLLVM.so.18.1-rust-1.78.0-stable(_ZN4llvm12writeArchiveENS_9StringRefENS_8ArrayRefINS_16NewArchiveMemberEEENS_17SymtabWritingModeENS_6object7Archive4KindEbbSt10unique_ptrINS_12MemoryBufferESt14default_deleteIS9_EEb+0x21b)[0x75bfb31f109b]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x5174d8c)[0x75bfb9b74d8c]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(_RNvXs_NtNtCskFMTEvEfYcy_18rustc_codegen_llvm4back7archiveNtB4_18LlvmArchiveBuilderNtNtNtCskzQGxkPzHAl_17rustc_codegen_ssa4back7archive14ArchiveBuilder5build+0x32c)[0x75bfb97c112c]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(_RNvNtNtCskzQGxkPzHAl_17rustc_codegen_ssa4back4link11link_binary+0x9b7)[0x75bfb97bdc05]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(_RNvXs5_CskFMTEvEfYcy_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCskzQGxkPzHAl_17rustc_codegen_ssa6traits7backend14CodegenBackend4link+0x24)[0x75bfb97bd224]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(_RNvMs4_NtCsfYYydOQbPZl_15rustc_interface7queriesNtB5_6Linker4link+0x307)[0x75bfb98f0d97]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x4bfcd63)[0x75bfb95fcd63]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x4f3eb6e)[0x75bfb993eb6e]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/librustc_driver-d6f66a8619a171d6.so(+0x4f3e9ca)[0x75bfb993e9ca]
/home/cm/mpv-winbuild-cmake/install_rustup/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-d2ef02247056996e.so(rust_metadata_std_e4dfbc2c3f4b09f1+0xc1145)[0x75bfbab35145]
/usr/lib/libc.so.6(+0x92ded)[0x75bfb48a6ded]
/usr/lib/libc.so.6(+0x1160dc)[0x75bfb492a0dc]

note: we would appreciate a report at https://github.com/rust-lang/rust
```

</p>
</details>