Repository: rust
Issue: Random `SIGSEGV: invalid memory reference` after update to Sonoma 14.2
Labels: I-crash,O-macos,T-compiler,S-needs-repro

## Problem
I used Ventura 13.2 and Xcode 14.3 on my M2 macbook to build without any problem, but since I updated to Sonoma 14.2 and Xcode 15, the problem appeared.
After using `cargo build` command random dependencies throw `SIGSEGV: invalid memory reference` error randomly. I have to retry `cargo build` until it compile successfully.

Example output:
```bash
Compiling serde v1.0.193
   Compiling libc v0.2.151
   Compiling cfg-if v1.0.0
   Compiling once_cell v1.19.0
   Compiling version_check v0.9.4
   Compiling itoa v1.0.10
thread panicked while processing panic. aborting.
error: could not compile `proc-macro2` (build script)

Caused by:
  process didn't exit successfully: `/Users/hoapq2/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name build_script_build --edition=2021 /Users/hoapq2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proc-macro2-1.0.71/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=132 --crate-type bin --emit=dep-info,link -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=f50446ec8a171ff3 -C extra-filename=-f50446ec8a171ff3 --out-dir /Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/build/proc-macro2-f50446ec8a171ff3 -L dependency=/Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: could not compile `once_cell` (lib)

Caused by:
  process didn't exit successfully: `/Users/hoapq2/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name once_cell --edition=2021 /Users/hoapq2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/once_cell-1.19.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=132 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="race"' --cfg 'feature="std"' -C metadata=8960163d904fd82f -C extra-filename=-8960163d904fd82f --out-dir /Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps -L dependency=/Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps --cap-lints allow` (signal: 6, SIGABRT: process abort signal)
error: could not compile `libc` (build script)

Caused by:
  process didn't exit successfully: `/Users/hoapq2/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name build_script_build /Users/hoapq2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.151/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=132 --crate-type bin --emit=dep-info,link -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="extra_traits"' --cfg 'feature="std"' -C metadata=f769b7461e28a7c6 -C extra-filename=-f769b7461e28a7c6 --out-dir /Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/build/libc-f769b7461e28a7c6 -L dependency=/Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
error: rustc interrupted by SIGSEGV, printing backtrace

error: could not compile `autocfg` (lib)

Caused by:
  process didn't exit successfully: `/Users/hoapq2/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name autocfg /Users/hoapq2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/autocfg-1.1.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=132 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C metadata=c259ddacc1677b72 -C extra-filename=-c259ddacc1677b72 --out-dir /Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps -L dependency=/Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
0   librustc_driver-b9265c333c46a764.dy 0x0000000109760ba0 _RNvNtCscRHTlojTVhD_17rustc_driver_impl14signal_handler17print_stack_trace + 52
1   libsystem_platform.dylib            0x0000000181051a24 _sigtramp + 56
2   dyld                                0x0000000180cafa78 _ZN5dyld412RuntimeState16_finalizeListTLVEPv + 116
3   dyld                                0x0000000180cafa78 _ZN5dyld412RuntimeState16_finalizeListTLVEPv + 116
4   libsystem_pthread.dylib             0x000000018101f978 _pthread_tsd_cleanup + 488
5   libsystem_pthread.dylib             0x0000000181022724 _pthread_exit + 84
6   libsystem_pthread.dylib             0x0000000181022040 _pthread_start + 148
7   libsystem_pthread.dylib             0x000000018101ce3c thread_start + 8

note: we would appreciate a report at https://github.com/rust-lang/rust
error: could not compile `version_check` (lib)

Caused by:
  process didn't exit successfully: `/Users/hoapq2/.rustup/toolchains/stable-aarch64-apple-darwin/bin/rustc --crate-name version_check /Users/hoapq2/.cargo/registry/src/index.crates.io-6f17d22bba15001f/version_check-0.9.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=132 --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C metadata=e21cba2a1838dbc6 -C extra-filename=-e21cba2a1838dbc6 --out-dir /Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps -L dependency=/Users/hoapq2/Desktop/RustyVoz/vozrs/target/debug/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)
```

## Steps
1. I use macbook pro m2 16gb ram with Sonoma 14.2 installed
2. Clone this repo https://github.com/HoaPham98/voz-rust.git
3. Use `cargo build` command

## Version
```bash
rustc 1.74.1 (a28077b28 2023-12-04)
binary: rustc
commit-hash: a28077b28a02b92985b3a3faecf92813155f1ea1
commit-date: 2023-12-04
host: aarch64-apple-darwin
release: 1.74.1
LLVM version: 17.0.4
```