diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc index bacd1c606f..e5f3ba1cfb 100644 --- a/src/runtime/runtime-collections.cc +++ b/src/runtime/runtime-collections.cc @@ -266,6 +266,11 @@ RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) { } Handle entries = isolate->factory()->NewFixedArray(max_entries * 2); + // Allocation can cause GC can delete weak elements. Reload. + if (max_entries > table->NumberOfElements()) { + max_entries = table->NumberOfElements(); + } + { DisallowHeapAllocation no_gc; int count = 0;