Bug 1638787 - Support return values and timeouts in JSRT fuzzing interface. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D75773
This commit is contained in:
Christian Holler 2020-05-18 15:54:18 +00:00
Родитель fe85cedb57
Коммит b016146686
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -139,6 +139,7 @@ function JSFuzzIterate() {
// 4) You must catch all exceptions. // 4) You must catch all exceptions.
let code = String.fromCharCode(...fuzzBuf); let code = String.fromCharCode(...fuzzBuf);
timed(3, _ => test(code)); timed(3, _ => test(code));
return 0;
} }
function testFile(file) { function testFile(file) {

Просмотреть файл

@ -115,13 +115,23 @@ int js::shell::FuzzJSRuntimeFuzz(const uint8_t* buf, size_t size) {
JS::SourceText<mozilla::Utf8Unit> srcBuf; JS::SourceText<mozilla::Utf8Unit> srcBuf;
if (!srcBuf.init(gCx, data, mozilla::ArrayLength(data) - 1, if (!srcBuf.init(gCx, data, mozilla::ArrayLength(data) - 1,
JS::SourceOwnership::Borrowed)) { JS::SourceOwnership::Borrowed)) {
return 0; return 1;
} }
JS::Evaluate(gCx, opts.setFileAndLine(__FILE__, __LINE__), srcBuf, &v); if (!JS::Evaluate(gCx, opts.setFileAndLine(__FILE__, __LINE__), srcBuf, &v) &&
!JS_IsExceptionPending(gCx)) {
// A return value of `false` without a pending exception indicates
// a timeout as triggered by the `timeout` shell function.
return 1;
}
// The fuzzing module is required to handle any exceptions // The fuzzing module is required to handle any exceptions
CrashOnPendingException(); CrashOnPendingException();
return 0; int32_t ret = 0;
if (!ToInt32(gCx, v, &ret)) {
MOZ_CRASH("Must return an int32 compatible return value!");
}
return ret;
} }