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

Improve integration on MSVC #358

Open
Eh2406 opened this issue Jan 7, 2024 · 3 comments
Open

Improve integration on MSVC #358

Eh2406 opened this issue Jan 7, 2024 · 3 comments

Comments

@Eh2406
Copy link

Eh2406 commented Jan 7, 2024

As of last week, asan and libfuzz are available for nightly rust on MSVC! I tried it out and got things working, but with some paper cuts that could probably easily be improved. Here's my experience report.

Cargo fuzz installed without trouble. Thanks to the recent change in nightly, even successfully compiled a fuzz target. (This is a huge step forward, the out-of-the-box experience now lets you check targets!) However when running that target a complaint about a missing DLL. After some digging it turned out to be clang_rt.asan_dynamic-x86_64.dll.

I spent a long time trying to figure out why I couldn't find that DLL. Even after checking with my Visual Studio installer that asan was installed and up to date. Then I noticed that I had an up-to-date copy of VS 2019, but the documentation said it was added in VS 2022. Several gigabytes of uninstall and reinstall later, and I copied it from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<version>\bin\Hostx86\x86 to the relevant target directory. And it successfully ran!

This morning I woke up to the console reporting that an assertion had failed, and a pop up box telling me that the program had crashed did I want to start a debugger. Opening the debugger did not get me any useful information, probably due to my lack of experience. Letting the program crash without opening the debugger terminated immediately. Unfortunately skipping the part of cargo fuzz that reported on the failing input and hash.

@RossSmyth
Copy link

RossSmyth commented Jul 23, 2024

I tried this procedure this evening. I can build the fuzz binary without any fussing. Running I had to do as described, though I got the DLL from the x64 subdirectory. After that is successfully starts the binary without immediately crashing, but it then does not do anything useful.

All I got was

INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 3265584444
INFO: Loaded 1 modules   (8869 inline 8-bit counters): 8869 [00007FF63AA38388, 00007FF63AA3A62D),
INFO: Loaded 1 PC tables (8869 PCs): 8869 [00007FF63A9DEC38,00007FF63AA01688),
INFO:        0 files found in [PROJECT DIRECTORY]
INFO: A corpus is not provided, starting from an empty corpus

and then the fuzzer hung there. After letting it sit for a couple minutes nothing further happened. I then hit Ctrl+C and the process ended. Nothing was populated in the corpus directory. I also just tried blindly copying everything that the asan DLL was found in just to see if it was missing something and it also did not work.

It seems close to working. I use libFuzzer for a C project on my computer so I know it works on Windows. For reference the terminal output with the C project is the following:

INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2246354909
INFO: Loaded 1 modules   (389 inline 8-bit counters): 389 [00007FF7E0B65188, 00007FF7E0B6530D),
INFO: Loaded 1 PC tables (389 PCs): 389 [00007FF7E0B1D7B8,00007FF7E0B1F008),
INFO:        0 files found in [PROJECT DIRECTORY]
INFO: A corpus is not provided, starting from an empty corpus
#2      INITED cov: 25 ft: 45 corp: 1/1b exec/s: 0 rss: 70Mb

and then it runs as normal immediately.

@RossSmyth
Copy link

Ok I got it working at home on an example project. The process is to add the directory the asan DLL is in to PATH.

@RossSmyth
Copy link

#379 Working on getting it working nicely. It mostly works now, but there are some kinks I've found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants