Skip to content

Commit c5fdb34

Browse files
Gabriel SchulhofMylesBorins
Gabriel Schulhof
authored andcommitted
deps: V8: cherry-pick e5dbc95
Original commit message: [api] Fix handle leak when getting Context embedder data The `Context::SlowGetAlignedPointerFromEmbedderData()` method returns a pointer, so the fact that it allocates handles is not obvious to the caller. Since this is the slow path anyway, simply add a handle scope inside of it. The tests are also modified to perform the same check for the `Object` equivalent of this method. Change-Id: I5f03c9a7b70b3a17315609df021606a53c9feb2d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1879902 Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#64583} Refs: v8/v8@e5dbc95 Fixes: #30127 Backport-PR-URL: #30109 PR-URL: #30130 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 553afa9 commit c5fdb34

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.13',
41+
'v8_embedder_string': '-node.14',
4242

4343
##### V8 defaults for Node.js #####
4444

deps/v8/src/api/api.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,7 @@ void Context::SetEmbedderData(int index, v8::Local<Value> value) {
13141314

13151315
void* Context::SlowGetAlignedPointerFromEmbedderData(int index) {
13161316
const char* location = "v8::Context::GetAlignedPointerFromEmbedderData()";
1317+
HandleScope handle_scope(GetIsolate());
13171318
i::Handle<i::EmbedderDataArray> data =
13181319
EmbedderDataFor(this, index, false, location);
13191320
if (data.is_null()) return nullptr;

deps/v8/test/cctest/test-api.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -2955,8 +2955,11 @@ THREADED_TEST(SetAlignedPointerInInternalFields) {
29552955

29562956
obj->SetAlignedPointerInInternalFields(2, indices, values);
29572957
CcTest::CollectAllGarbage();
2958-
CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(0));
2959-
CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(1));
2958+
{
2959+
v8::SealHandleScope no_handle_leak(isolate);
2960+
CHECK_EQ(heap_allocated_1, obj->GetAlignedPointerFromInternalField(0));
2961+
CHECK_EQ(heap_allocated_2, obj->GetAlignedPointerFromInternalField(1));
2962+
}
29602963

29612964
indices[0] = 1;
29622965
indices[1] = 0;
@@ -3009,6 +3012,7 @@ THREADED_TEST(EmbedderDataAlignedPointers) {
30093012
}
30103013
CcTest::CollectAllGarbage();
30113014
for (int i = 0; i < 100; i++) {
3015+
v8::SealHandleScope no_handle_leak(env->GetIsolate());
30123016
CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i));
30133017
}
30143018
}

0 commit comments

Comments
 (0)