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

[BUG] hwasan miscompilation #2064

Closed
fmayer opened this issue Aug 29, 2024 · 4 comments
Closed

[BUG] hwasan miscompilation #2064

fmayer opened this issue Aug 29, 2024 · 4 comments
Assignees
Labels

Comments

@fmayer
Copy link

fmayer commented Aug 29, 2024

Description

Given this program

float frexpf(float, int*);

int main() {
  int e;
  float m = frexpf(1, &e);
  __asm volatile("": :"w"(m));
  return 0;
}

Built like this

clang -c \
  -target aarch64-linux-android10000 \
  -O2 -flto=thin -fsanitize=hwaddress \
  -o test.o \
  test.c
ld.lld -r test.o -o partial.o

NDK 27 generates code that crashes with a HWASan tag-mismatch. This is a regression compared to NDK 26c.

This is being fixed in upstream LLVM in llvm/llvm-project#106624

Affected versions

r27

Canary version

No response

Host OS

Linux

Host OS version

Debian

Affected ABIs

arm64-v8a

Build system

Other (specify below)

Other build system

No response

minSdkVersion

n/a

Device API level

No response

@fmayer fmayer added the bug label Aug 29, 2024
@github-project-automation github-project-automation bot moved this to Unconfirmed in NDK r27c Aug 29, 2024
@github-project-automation github-project-automation bot moved this to Unconfirmed in NDK r28 Aug 29, 2024
@DanAlbert DanAlbert added this to LLVM Aug 29, 2024
@github-project-automation github-project-automation bot moved this to Awaiting triage in LLVM Aug 29, 2024
@DanAlbert DanAlbert moved this from Awaiting triage to Awaiting prebuilt drop in LLVM Aug 29, 2024
@DanAlbert DanAlbert moved this from Unconfirmed to Needs prebuilt update in NDK r27c Aug 29, 2024
@DanAlbert DanAlbert moved this from Unconfirmed to Needs prebuilt update in NDK r28 Aug 29, 2024
@appujee
Copy link
Collaborator

appujee commented Aug 30, 2024

The only difference i see between clang-17 and clang-18 is the llvm.lifetime.start.p0 and llvm.lifetime.end.p0 markers

https://godbolt.org/z/qGhT5ne7P

That does affect the schedule of instruction in the final assembly. https://godbolt.org/z/vo7Mj8Kz9

Left side is clang-trunk and right side clang-17
image

@fmayer
Copy link
Author

fmayer commented Aug 30, 2024

The bug is already found. It's about AttrInfer adding assumptions about libc functions that are incorrect for HWAsan

@pirama-arumuga-nainar
Copy link
Collaborator

There is discussion in internal bug b/362408260. This issue tracks backporting the fix to r27.

@fmayer
Copy link
Author

fmayer commented Sep 5, 2024

Cherry-picked onto LLVM r522817 (NDK 27 uses that) and r530567 (and main branch)

@DanAlbert DanAlbert moved this from Awaiting prebuilt drop to Prebuilts submitted in LLVM Sep 26, 2024
@DanAlbert DanAlbert moved this from Needs prebuilt update to Merged in NDK r28 Sep 26, 2024
@DanAlbert DanAlbert moved this from Needs prebuilt update to Needs cherry-pick in NDK r27c Sep 26, 2024
@github-project-automation github-project-automation bot moved this from Needs cherry-pick to Merged in NDK r27c Sep 30, 2024
@DanAlbert DanAlbert moved this from Merged to Needs cherry-pick in NDK r27c Sep 30, 2024
@DanAlbert DanAlbert moved this from Needs cherry-pick to Needs prebuilt update in NDK r27c Sep 30, 2024
@DanAlbert DanAlbert moved this from Needs prebuilt update to Merged in NDK r27c Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Prebuilts submitted
Status: Merged
Status: Merged
Development

No branches or pull requests

4 participants