Bug 1245861 - Ensure ShellRuntime's PersistentRooteds are always initialized. r=jonco

This commit is contained in:
Jan de Mooij 2016-02-08 15:13:46 +01:00
parent 6246516299
commit 63eecc3ef2
2 changed files with 12 additions and 7 deletions

View File

@ -0,0 +1,3 @@
if (helperThreadCount() === 0)
quit();
evalInWorker("setInterruptCallback(function() {}); timeout(1000);");

View File

@ -139,7 +139,7 @@ static const double MAX_TIMEOUT_INTERVAL = 1800.0;
// Per-runtime shell state. // Per-runtime shell state.
struct ShellRuntime struct ShellRuntime
{ {
ShellRuntime(); explicit ShellRuntime(JSRuntime* rt);
bool isWorker; bool isWorker;
double timeoutInterval; double timeoutInterval;
@ -287,12 +287,14 @@ extern JS_EXPORT_API(void) add_history(char* line);
} // extern "C" } // extern "C"
#endif #endif
ShellRuntime::ShellRuntime() ShellRuntime::ShellRuntime(JSRuntime* rt)
: isWorker(false), : isWorker(false),
timeoutInterval(-1.0), timeoutInterval(-1.0),
serviceInterrupt(false), serviceInterrupt(false),
haveInterruptFunc(false), haveInterruptFunc(false),
interruptFunc(rt, NullValue()),
lastWarningEnabled(false), lastWarningEnabled(false),
lastWarning(rt, NullValue()),
watchdogLock(nullptr), watchdogLock(nullptr),
watchdogWakeup(nullptr), watchdogWakeup(nullptr),
watchdogThread(nullptr), watchdogThread(nullptr),
@ -2771,7 +2773,7 @@ WorkerMain(void* arg)
return; return;
} }
UniquePtr<ShellRuntime> sr = MakeUnique<ShellRuntime>(); UniquePtr<ShellRuntime> sr = MakeUnique<ShellRuntime>(rt);
if (!sr) { if (!sr) {
JS_DestroyRuntime(rt); JS_DestroyRuntime(rt);
js_delete(input); js_delete(input);
@ -2825,6 +2827,9 @@ WorkerMain(void* arg)
JS::SetLargeAllocationFailureCallback(rt, nullptr, nullptr); JS::SetLargeAllocationFailureCallback(rt, nullptr, nullptr);
DestroyContext(cx, false); DestroyContext(cx, false);
KillWatchdog(rt);
JS_DestroyRuntime(rt); JS_DestroyRuntime(rt);
js_delete(input); js_delete(input);
@ -6994,7 +6999,7 @@ main(int argc, char** argv, char** envp)
if (!rt) if (!rt)
return 1; return 1;
UniquePtr<ShellRuntime> sr = MakeUnique<ShellRuntime>(); UniquePtr<ShellRuntime> sr = MakeUnique<ShellRuntime>(rt);
if (!sr) if (!sr)
return 1; return 1;
@ -7006,9 +7011,6 @@ main(int argc, char** argv, char** envp)
if (!SetRuntimeOptions(rt, op)) if (!SetRuntimeOptions(rt, op))
return 1; return 1;
sr->interruptFunc.init(rt, NullValue());
sr->lastWarning.init(rt, NullValue());
JS_SetGCParameter(rt, JSGC_MAX_BYTES, 0xffffffff); JS_SetGCParameter(rt, JSGC_MAX_BYTES, 0xffffffff);
size_t availMem = op.getIntOption("available-memory"); size_t availMem = op.getIntOption("available-memory");