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

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

Open
Lee-Janggun opened this issue Feb 26, 2024 · 6 comments
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-macos Operating system: macOS

Comments

@Lee-Janggun
Copy link
Contributor

Lee-Janggun commented Feb 26, 2024

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

@Lee-Janggun Lee-Janggun added the C-bug Category: This is a bug. label Feb 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 26, 2024
@Lee-Janggun
Copy link
Contributor Author

Strangely, running just the leak sanitizer complains that this is an unsupported target.

Running

RUSTFLAGS="-Z sanitizer=leak" cargo +nightly run

results in

# A bunch of error lines
--- stderr
  error: leak sanitizer is not supported for this target

  error: aborting due to 1 previous error

so it may be the case that leak sanitizer is simply not supported?

@Urgau
Copy link
Member

Urgau commented Feb 26, 2024

Seems like a known issue #88132

// FIXME: The leak sanitizer currently fails the tests, see #88132.

@Lee-Janggun
Copy link
Contributor Author

Thanks for the pointer! I think this issue in itself is different, since that one is a hang and this one is a false positive (or an real error in the rust runtime somewhere).

@Lee-Janggun
Copy link
Contributor Author

Relevant LLVM thread: https://discourse.llvm.org/t/does-leaksanitizer-not-work-on-macos-13-apple-silicon/73148

Unfortunately it seems that this will not be fixed in the short time...

@jieyouxu jieyouxu added A-sanitizers Area: Sanitizers for correctness and code quality O-AArch64 Armv8-A or later processors in AArch64 mode and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 26, 2024
@madsmtm
Copy link
Contributor

madsmtm commented Nov 12, 2024

@rustbot label O-macos

@madsmtm
Copy link
Contributor

madsmtm commented Nov 13, 2024

I have opened llvm/llvm-project#115992 to inform the LLVM developers of this issue (not entirely sure where the bug tracking for sanitizers happen).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sanitizers Area: Sanitizers for correctness and code quality C-bug Category: This is a bug. O-AArch64 Armv8-A or later processors in AArch64 mode O-macos Operating system: macOS
Projects
None yet
Development

No branches or pull requests

5 participants