Repository: rust
Issue: AddressSanitizer reports leak for empty main function on macOS for aarch64-apple-darwin
Labels: O-macos,A-sanitizers,C-bug,O-AArch64

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

Code:

```rust
fn main() {}
```

Command:
```
RUSTFLAGS="-Z sanitizer=address" ASAN_OPTIONS=detect_leaks=1 cargo +nightly run -Z build-std --target aarch64-apple-darwin
```

I expected to see this happen: nothing.

Instead, this happened: leak reported, full report below.



### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.78.0-nightly (0ecbd0605 2024-02-25)
binary: rustc
commit-hash: 0ecbd0605770f45c9151715e66ba2b3cae367fcb
commit-date: 2024-02-25
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 18.1.0
```

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary>Message</summary>
<p>

```
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/leak_test`

=================================================================
==42548==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x104e92ea4 in malloc+0x6c (librustc-nightly_rt.asan.dylib:arm64+0x4eea4)
    #1 0x18ce23788 in dyld4::RuntimeState::_instantiateTLVs(unsigned long)+0xd8 (dyld:arm64+0xfffffffffff5d788)
    #2 0x6a5f00018d19e688  (<unknown module>)
    #3 0x57380001045bd698  (<unknown module>)
    #4 0x1045b9af8 in std::rt::lang_start_internal::h1eb653699f840ea4+0x294 (leak_test:arm64+0x100015af8)
    #5 0x1045a5624 in std::rt::lang_start::h2668e3698e5b2b03 rt.rs:165
    #6 0x1045a5930 in main+0x20 (leak_test:arm64+0x100001930)
    #7 0x18ce150dc  (<unknown module>)
    #8 0xbc4d7ffffffffffc  (<unknown module>)

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x104e92ea4 in malloc+0x6c (librustc-nightly_rt.asan.dylib:arm64+0x4eea4)
    #1 0x18cdca65c in _fetchInitializingClassList(bool)+0x2c (libobjc.A.dylib:arm64+0xa65c)
    #2 0x187280018cdca530  (<unknown module>)
    #3 0x803d80018cdca374  (<unknown module>)
    #4 0xfa5380018cdca1ec  (<unknown module>)
    #5 0xf91580018cdca1ec  (<unknown module>)
    #6 0x9f0a00018cdca1ec  (<unknown module>)
    #7 0xcd5900018cde7300  (<unknown module>)
    #8 0x8d1a00018cdc9dc0  (<unknown module>)
    #9 0x441c00018cdc9760  (<unknown module>)
    #10 0xda1d00018ceab444  (<unknown module>)
    #11 0x920580018ceaa800  (<unknown module>)
    #12 0xe635800199a43678  (<unknown module>)
    #13 0xad5080018ce31a20  (<unknown module>)
    #14 0xf14a00018ce77324  (<unknown module>)
    #15 0x192000018ce6a664  (<unknown module>)
    #16 0x121780018ce112f8  (<unknown module>)
    #17 0x120700018ce6969c  (<unknown module>)
    #18 0x9f7f00018ce76e38  (<unknown module>)
    #19 0xfa3f80018ce2db34  (<unknown module>)
    #20 0x4f3180018ce37924  (<unknown module>)
    #21 0xce4d00018ce5335c  (<unknown module>)
    #22 0xe96b00018ce15f9c  (<unknown module>)
    #23 0x525300018ce14ed8  (<unknown module>)
    #24 0xbc4d7ffffffffffc  (<unknown module>)

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x104e9317c in calloc+0x74 (librustc-nightly_rt.asan.dylib:arm64+0x4f17c)
    #1 0x18cdca6b8 in _fetchInitializingClassList(bool)+0x88 (libobjc.A.dylib:arm64+0xa6b8)
    #2 0x187280018cdca530  (<unknown module>)
    #3 0x803d80018cdca374  (<unknown module>)
    #4 0xfa5380018cdca1ec  (<unknown module>)
    #5 0xf91580018cdca1ec  (<unknown module>)
    #6 0x9f0a00018cdca1ec  (<unknown module>)
    #7 0xcd5900018cde7300  (<unknown module>)
    #8 0x8d1a00018cdc9dc0  (<unknown module>)
    #9 0x441c00018cdc9760  (<unknown module>)
    #10 0xda1d00018ceab444  (<unknown module>)
    #11 0x920580018ceaa800  (<unknown module>)
    #12 0xe635800199a43678  (<unknown module>)
    #13 0xad5080018ce31a20  (<unknown module>)
    #14 0xf14a00018ce77324  (<unknown module>)
    #15 0x192000018ce6a664  (<unknown module>)
    #16 0x121780018ce112f8  (<unknown module>)
    #17 0x120700018ce6969c  (<unknown module>)
    #18 0x9f7f00018ce76e38  (<unknown module>)
    #19 0xfa3f80018ce2db34  (<unknown module>)
    #20 0x4f3180018ce37924  (<unknown module>)
    #21 0xce4d00018ce5335c  (<unknown module>)
    #22 0xe96b00018ce15f9c  (<unknown module>)
    #23 0x525300018ce14ed8  (<unknown module>)
    #24 0xbc4d7ffffffffffc  (<unknown module>)

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x104e9317c in calloc+0x74 (librustc-nightly_rt.asan.dylib:arm64+0x4f17c)
    #1 0x18cdca694 in _fetchInitializingClassList(bool)+0x64 (libobjc.A.dylib:arm64+0xa694)
    #2 0x187280018cdca530  (<unknown module>)
    #3 0x803d80018cdca374  (<unknown module>)
    #4 0xfa5380018cdca1ec  (<unknown module>)
    #5 0xf91580018cdca1ec  (<unknown module>)
    #6 0x9f0a00018cdca1ec  (<unknown module>)
    #7 0xcd5900018cde7300  (<unknown module>)
    #8 0x8d1a00018cdc9dc0  (<unknown module>)
    #9 0x441c00018cdc9760  (<unknown module>)
    #10 0xda1d00018ceab444  (<unknown module>)
    #11 0x920580018ceaa800  (<unknown module>)
    #12 0xe635800199a43678  (<unknown module>)
    #13 0xad5080018ce31a20  (<unknown module>)
    #14 0xf14a00018ce77324  (<unknown module>)
    #15 0x192000018ce6a664  (<unknown module>)
    #16 0x121780018ce112f8  (<unknown module>)
    #17 0x120700018ce6969c  (<unknown module>)
    #18 0x9f7f00018ce76e38  (<unknown module>)
    #19 0xfa3f80018ce2db34  (<unknown module>)
    #20 0x4f3180018ce37924  (<unknown module>)
    #21 0xce4d00018ce5335c  (<unknown module>)
    #22 0xe96b00018ce15f9c  (<unknown module>)
    #23 0x525300018ce14ed8  (<unknown module>)
    #24 0xbc4d7ffffffffffc  (<unknown module>)

SUMMARY: AddressSanitizer: 240 byte(s) leaked in 4 allocation(s).
```

</p>
</details>