Bug 1211939 - Don't call JSRuntime::onOutOfMemory from helper threads. r=jonco

This commit is contained in:
Jan de Mooij 2015-10-14 12:37:02 +02:00
Родитель e9fd48c65a
Коммит d3a0b9cc9d
3 изменённых файлов: 6 добавлений и 1 удалений

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

@ -142,6 +142,8 @@ struct Zone : public JS::shadow::Zone,
void onTooMuchMalloc();
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
if (!CurrentThreadCanAccessRuntime(runtime_))
return nullptr;
return runtimeFromMainThread()->onOutOfMemory(allocFunc, nbytes, reallocPtr);
}
void reportAllocationOverflow() { js::ReportAllocationOverflow(nullptr); }

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

@ -163,7 +163,9 @@ class ExclusiveContext : public ContextFriendFields,
}
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
return runtime_->onOutOfMemory(allocFunc, nbytes, reallocPtr, maybeJSContext());
if (!isJSContext())
return nullptr;
return runtime_->onOutOfMemory(allocFunc, nbytes, reallocPtr, asJSContext());
}
/* Clear the pending exception (if any) due to OOM. */

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

@ -760,6 +760,7 @@ JSRuntime::onOutOfMemory(AllocFunction allocFunc, size_t nbytes, void* reallocPt
JSContext* maybecx)
{
MOZ_ASSERT_IF(allocFunc != AllocFunction::Realloc, !reallocPtr);
MOZ_ASSERT(CurrentThreadCanAccessRuntime(this));
if (isHeapBusy())
return nullptr;