Skip to content

Commit

Permalink
Merge the fuzzers used by oss-fuzz and internal fuzzers
Browse files Browse the repository at this point in the history
Summary:
Add a time limit to the execution runtime of JS code, to prevent infinite loops
in generated JS being reported as timeouts in Hermes.

Reviewed By: neildhar

Differential Revision: D21726590

fbshipit-source-id: c99c41309807294a7af50e4891605eac843cda3f
  • Loading branch information
Riley Dulin authored and facebook-github-bot committed May 29, 2020
1 parent b80bbe8 commit 47ce36a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/fuzzers/fuzzer-jsi-entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
std::string s(reinterpret_cast<const char *>(data), size);
s.append("\0");
auto runtime = makeHermesRuntime();
// Cap the run-time of the code so that fuzzing can stay efficient.
constexpr uint32_t kTimeoutForRunningInMs = 10000;
runtime->watchTimeLimit(kTimeoutForRunningInMs);

try {
runtime->evaluateJavaScript(std::make_unique<StringBuffer>(s), "");
Expand Down

0 comments on commit 47ce36a

Please sign in to comment.