Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: src/api.cc

Issue 2427623002: Fix OOM handling on a background thread. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index aed4af089b7c5b1eeb79194fa1622feba4c0daee..919e8394d0a0e122fecf26b24ede617937374240 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -274,10 +274,23 @@ void i::V8::FatalProcessOutOfMemory(const char* location, bool is_heap_oom) {
i::Isolate* isolate = i::Isolate::Current();
char last_few_messages[Heap::kTraceRingBufferSize + 1];
char js_stacktrace[Heap::kStacktraceBufferSize + 1];
+ i::HeapStats heap_stats;
+
+ if (isolate == nullptr) {
+ // On a background thread -> we cannot retrieve memory information from the
+ // Isolate. Write easy-to-recognize values on the stack.
+ memset(last_few_messages, 0x0badc0de, Heap::kTraceRingBufferSize + 1);
+ memset(js_stacktrace, 0x0badc0de, Heap::kStacktraceBufferSize + 1);
+ memset(&heap_stats, 0xbadc0de, sizeof(heap_stats));
+ // Note that the embedder's oom handler won't be called in this case. We
+ // just crash.
+ FATAL("API fatal error handler returned after process out of memory");
+ return;
+ }
+
memset(last_few_messages, 0, Heap::kTraceRingBufferSize + 1);
memset(js_stacktrace, 0, Heap::kStacktraceBufferSize + 1);
- i::HeapStats heap_stats;
intptr_t start_marker;
heap_stats.start_marker = &start_marker;
size_t new_space_size;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698