rust-lang / rust-lang/rust

AddressSanitizer reports leak for empty main function on macOS for aarch64-apple-darwin

Open
#121,624 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-sanitizers C-bug llvm-fixed-upstream O-AArch64 O-macos
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code:

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

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
Message

    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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the minimal fn main() {} case with the reported nightly cargo +nightly run -Z build-std --target aarch64-apple-darwin command and AddressSanitizer leak detection enabled. The report names no repository file or test; done means determining the cause and ensuring this empty program no longer reports the 240-byte leak, or documenting the confirmed platform limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.