Skip to content

Commit

Permalink
[v14.x] deps: V8: cherry-pick 81181a8ad80a
Browse files Browse the repository at this point in the history
Original commit message:

    [JSON] Fix GC issue in BuildJsonObject
    We must ensure that the sweeper is not running or has already swept
    mutable_double_buffer. Otherwise the GC can add it to the free list.

    Bug: v8:11837
    Change-Id: Ifd9cf15f1c94f664fd6489c70bb38b59730cdd78
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2928181
    Commit-Queue: Victor Gomes <[email protected]>
    Reviewed-by: Toon Verwaest <[email protected]>
    Reviewed-by: Dominik Inführ <[email protected]>
    Cr-Commit-Position: refs/heads/master@{#74859}

Refs: v8/v8@81181a8
  • Loading branch information
thomasmichaelwallace committed Jun 28, 2021
1 parent f04a702 commit 3e269f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.67',
'v8_embedder_string': '-node.68',

##### V8 defaults for Node.js #####

Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/heap/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3347,6 +3347,10 @@ void Heap::MakeHeapIterable() {
mark_compact_collector()->EnsureSweepingCompleted();
}

void Heap::EnsureSweepingCompleted() {
mark_compact_collector()->EnsureSweepingCompleted();
}

namespace {

double ComputeMutatorUtilizationImpl(double mutator_speed, double gc_speed) {
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/heap/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,8 @@ class Heap {
Reservation* reservations, const std::vector<HeapObject>& large_objects,
const std::vector<Address>& maps);

void EnsureSweepingCompleted();

IncrementalMarking* incremental_marking() {
return incremental_marking_.get();
}
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/json/json-parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,11 @@ Handle<Object> JsonParser<Char>::BuildJsonObject(
DCHECK_EQ(mutable_double_address, end);
}
#endif
// Before setting the length of mutable_double_buffer back to zero, we
// must ensure that the sweeper is not running or has already swept the
// object's page. Otherwise the GC can add the contents of
// mutable_double_buffer to the free list.
isolate()->heap()->EnsureSweepingCompleted();
mutable_double_buffer->set_length(0);
}
}
Expand Down

0 comments on commit 3e269f2

Please sign in to comment.