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

[FR] clang compiler driver should reject unsupported sanitizers #1958

Open
serhiihuralniksc opened this issue Oct 25, 2023 · 10 comments
Open

Comments

@serhiihuralniksc
Copy link

Description

Getting this with -fsanitize=memory:

ld.lld: error: cannot open <my_ndk_r26>/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/17/lib/linux/libclang_rt.msan-aarch64-android.a: No such file or directory

Not sure if it is bug or conscious choice for r26, so opening as FR.

Can we have msan rt lib in NDK?

@pirama-arumuga-nainar
Copy link
Collaborator

msan is not one of the supported sanitizers on Android. See google/sanitizers#1381.

If you're debugging memory initialization issues, you can use the options in https://source.android.com/docs/security/test/memory-safety/zero-initialized-memory#zero-initialized-userspace to zero|patten initialize the stack and zero-initialize the heap.

@enh-google
Copy link
Collaborator

(see also https://developer.android.com/ndk/guides/hwasan which is the main thing we use within Android to find memory errors --- i certainly do all my development with hwasan enabled.)

@serhiihuralniksc
Copy link
Author

@pirama-arumuga-nainar @enh-google Thanks you for answers/recommendations!

Then, if msan is not supported, should NDK maybe give some explicit error about it? I can imagine that you'll periodically get tickets from impatient users (like I am :)). I guess that you see no point in tweaking clang driver to reject -fsanitize=memory. If so - can we maybe have libclang_rt.msan-XXX-android.a in the NDK in a form of a linker script that aborts process with some message, like maybe:

ASSERT(0, "msan is not supported, consider other alternatives")

I haven't tried this but assume it should work as NDK already has supplemental linker scripts for libc++.
Obviously this will fail build quite late and rejecting CLI option at driver level would be more user-friendly but it is still an option that might be easier for you to implement.

@DanAlbert
Copy link
Member

if msan is not supported, should NDK maybe give some explicit error about it?

It rarely has much to do with what we want. It's about what LLVM will accept. They might accept that? @pirama-arumuga-nainar?

@enh-google
Copy link
Collaborator

(@appujee filed an internal bug that mentions that iOS/macOS already has an equivalent check.)

@DanAlbert
Copy link
Member

That's promising then. I'll retitle this bug for that.

@DanAlbert DanAlbert changed the title [FR] Add msan runtime support [FR] clang compiler driver should reject unsupported sanitizers Oct 25, 2023
@agrieve
Copy link

agrieve commented Apr 24, 2024

Is ASAN still not supported? I just burned a good amount of time on this, because:

This page suggests that it is supported, except for arm64 platform development (I'm using the 16k pages emulator).

This page also says it's supported.

This page says it's not supported, but still documents how to use it and does not say it is broken.

This page says hwasan is supported only for arm64.

Is there no longer any way to do msan in any form on an emulator?

Maybe as a part of this bug, the docs I found could be updated as well?

@enh-google

This comment was marked as off-topic.

@enh-google

This comment was marked as off-topic.

@DanAlbert

This comment was marked as off-topic.

@github-project-automation github-project-automation bot moved this to Awaiting triage in LLVM Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Awaiting triage
Development

No branches or pull requests

5 participants