This is an archive of the discontinued LLVM Phabricator instance.

[fuzzer] Add basic support for emscripten.
ClosedPublic

Authored by metzman on Dec 10 2019, 10:13 AM.

Details

Summary

Add basic support for emscripten.

This enables libFuzzer to build (using build.sh) for emscripten and fuzz
a target compiled with
-fsanitize-coverage=inline-8bit-counters.

Basic fuzzing and bug finding work with this commit.
RSS limit and timeouts will not work because they depend on system
functions that are not implemented/widely supported in emscripten.

Diff Detail

Event Timeline

metzman created this revision.Dec 10 2019, 10:13 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 10 2019, 10:13 AM
Herald added subscribers: llvm-commits, Restricted Project. · View Herald Transcript
metzman updated this revision to Diff 233150.Dec 10 2019, 11:01 AM
  • fix comment
metzman edited the summary of this revision. (Show Details)Dec 10 2019, 11:07 AM

Demo https://jonathanmetzman.github.io/wasm-fuzzing-demo/brotli/decode_fuzzer.html

Note that with this CL one needs to open the console to see libFuzzer's output, in the demo it appears on the page.
I may not land that change because it hurts performance and requires bigger changes to libFuzzer than I want to deal with now.

metzman edited the summary of this revision. (Show Details)Dec 10 2019, 11:18 AM
hctim added inline comments.Dec 10 2019, 1:50 PM
compiler-rt/lib/fuzzer/FuzzerDriver.cpp
287

Can we hoist this into the caller - having:

if (!LIBFUZZER_EMSCRIPTEN)
  StartRssThread(F, A);

... seems clearer to me than silently not doing the thing the function says it does some of the time.

metzman retitled this revision from Summary: [fuzzer] Add basic support for emscripten. to [fuzzer] Add basic support for emscripten..Dec 10 2019, 5:43 PM
metzman edited the summary of this revision. (Show Details)
metzman updated this revision to Diff 233245.Dec 10 2019, 5:56 PM
  • hoist as requested
Harbormaster completed remote builds in B42270: Diff 233246.
metzman marked 2 inline comments as done.Dec 10 2019, 6:03 PM
metzman added inline comments.
compiler-rt/lib/fuzzer/FuzzerDriver.cpp
287

Done.
Do you like the way I did it now (with an #if macro?) or do you want the if to be code? (I guess the macro way might result in a complaint about unused function and is IMO uglier but clearer.

hctim accepted this revision.Dec 11 2019, 7:43 AM
hctim marked an inline comment as done.
hctim added inline comments.
compiler-rt/lib/fuzzer/FuzzerDriver.cpp
287

I believe this is the canonical way to guard features around macros, so LGTM. If we have any -Wunused-function problems then we can guard against it later.

This revision is now accepted and ready to land.Dec 11 2019, 7:43 AM
metzman updated this revision to Diff 233441.Dec 11 2019, 1:21 PM
metzman marked an inline comment as done.
  • fix comment
This revision was automatically updated to reflect the committed changes.