This is an archive of the discontinued LLVM Phabricator instance.

Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.
AbandonedPublic

Authored by metzman on Aug 20 2018, 4:17 PM.

Details

Reviewers
morehouse
Summary

This allows -fsanitize=fuzzer and -fsanitize=fuzzer-no-link for the MSVC toolchain (Windows).
When using either when targeting MSVC, Clang will also use some default flags that are needed (such as incremental linking and debug).

Diff Detail

Repository
rC Clang

Event Timeline

metzman created this revision.Aug 20 2018, 4:17 PM
metzman edited the summary of this revision. (Show Details)Aug 20 2018, 4:28 PM
metzman edited the summary of this revision. (Show Details)Aug 20 2018, 4:33 PM

Matt could you please take a look at this?
I'll add rnk as reviewer once you sign off, since he is a CODE_OWNER for Windows in Clang.

Thanks!

LGTM

lib/Driver/ToolChains/MSVC.cpp
373

Why is -debug needed?

metzman added inline comments.Aug 20 2018, 5:50 PM
lib/Driver/ToolChains/MSVC.cpp
373

Without it, libFuzzer quits early with the following error message:

ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.

I think it's because sancov.module_ctor isn't executed (or it isn't calling the init functions in libFuzzer), but I'm not 100% sure about this (or why this is the case).

I guess -debug isn't strictly necessary because I don't have libFuzzer working perfectly without ASAN yet (I always get warnings from libFuzzer about __sanitizer_print_stack_trace, __sanitizer_acquire_crash_state, and __sanitizer_set_death_callback being missing) and ASAN includes this argument (as well as -incremental:no, removing this line doesn't break anything as long as we always compile with ASAN).
Do you think I should remove these two arguments?

I was planning on tracking down why exactly this occurs later on, but I'm fine doing this now.

metzman abandoned this revision.Aug 21 2018, 12:53 PM

Abandoning this revision since I think the libFuzzer on Windows changes would be easier to understand as part of one commit instead of three.
New revision here