llvm-mingw icon indicating copy to clipboard operation
llvm-mingw copied to clipboard

Error running address sanitizer on basic input

Open caymaynard opened this issue 10 months ago • 7 comments

OS: windows 11 mingw-llvm: 19.1.7 with UCRT

Similar to https://github.com/llvm/llvm-project/issues/82450, I have been encountering an error when running address sanitizer.

main.c:

int main(int argc, char **argv) {}

compiled with clang -fsanitize=address main.c

Unlike the previous issue though, I get a different unhandled instruction

==17396==interception_win: unhandled instruction at 0x7ffb63223a40: 44 0f b6 1a 4c 8b d2 48
==17396==interception_win: unhandled instruction at 0x7ffb63223a40: 44 0f b6 1a 4c 8b d2 48

CMIIW, but it looks like this instruction is supposed to be handled by ASAN in https://github.com/llvm/llvm-project/blob/b8cdc5ea2741c7e4062bb211bac7033189b4d802/compiler-rt/lib/interception/interception_win.cpp#L905

Is there some macro definition which is required to correctly interpret the instruction?

caymaynard avatar Jan 29 '25 00:01 caymaynard

Interestingly, yesterday there was a similar report at MSYS2 discord: https://discord.com/channels/792780131906617355/792780132398006315/1333809892074590309

I can reproduce neither on Win 11, using the 64-bit UCRT toolchain.

mati865 avatar Jan 29 '25 07:01 mati865

A lot of fixes for unhandled instructions have been merged quite recently; do you get the same issues still with e.g. the latest nightly builds? https://github.com/mstorsjo/llvm-mingw/releases/nightly

mstorsjo avatar Jan 29 '25 07:01 mstorsjo

CC @bernhardu

mstorsjo avatar Jan 29 '25 07:01 mstorsjo

Thanks for the information.

But as far as I see the instruction 44 0f b6 1a got added in this patch to main branch four month ago, which mentions some relation to "the 24H2 update for Windows 11".

Unfortunately these got not backported to the release/19.x branch where the file compiler-rt/lib/interception/interception_win.cpp got last updated in march.

Backporting https://github.com/llvm/llvm-project/commit/ce4618a9c405bd8a9c1e096eb45e9ca83d3891f1 and https://github.com/llvm/llvm-project/commit/8417f6af54 to the 19.x branch might be a good thing, as there may more users to be expected getting this updates?

I hope it is ok to CC @zmodem too, as I am new to llvm-project and not sure how backporting in llvm-project is handled.

bernhardu avatar Jan 29 '25 19:01 bernhardu

But as far as I see the instruction 44 0f b6 1a got added in this patch to main branch four month ago, which mentions some relation to "the 24H2 update for Windows 11".

Unfortunately these got not backported to the release/19.x branch where the file compiler-rt/lib/interception/interception_win.cpp got last updated in march.

Backporting llvm/llvm-project@ce4618a and llvm/llvm-project@8417f6af54 to the 19.x branch might be a good thing, as there may more users to be expected getting this updates?

The LLVM release process currently is such that there's probably no more releases of 19.x to be expected (and if there are, it's mostly for really critical fixes). But 20.x got branched today, and the first RC will be released by the end of the week, so there'll be a prerelease of llvm-mingw built from that soon thereafter as well.

Outside of the main llvm release process, e.g. msys2 also backport a number of patches to their packages, so there you can sometimes get e.g. a 19.x release build with patches that otherwise would wait to 20.x.

And within llvm-mingw, I make nightly builds that are available at https://github.com/mstorsjo/llvm-mingw/releases/nightly, to make it easy to test things out, whether things have been fixed in the latest git.

mstorsjo avatar Jan 29 '25 19:01 mstorsjo

Thanks for the details!

I have tested against the nightly build (built from https://github.com/llvm/llvm-project.git 617278e7b0c937fccbf7d67d14f053c3409bc33f) and the address sanitizer works on my machine now.

I only need this for debugging a stack corruption issue I was facing, so I personally am fine with using the nightly builds until 20.x is released.

caymaynard avatar Jan 29 '25 21:01 caymaynard

I can confirm that using a recent nightly build allows me to successfully run programs compiled with -fsanitize=address. The issue appeared after the 24H2 update as mentioned previously in the thread.

akoluthic avatar Feb 06 '25 13:02 akoluthic