ndk
ndk copied to clipboard
[BUG] hwasan miscompilation
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 https://github.com/llvm/llvm-project/pull/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
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
The bug is already found. It's about AttrInfer adding assumptions about libc functions that are incorrect for HWAsan
There is discussion in internal bug b/362408260. This issue tracks backporting the fix to r27.
Cherry-picked onto LLVM r522817 (NDK 27 uses that) and r530567 (and main branch)