|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Shelley Vohr <shelley.vohr@gmail.com> |
| 3 | +Date: Sun, 23 Oct 2022 23:36:19 +0200 |
| 4 | +Subject: fix: prevent changing FunctionTemplateInfo after publish |
| 5 | + |
| 6 | +Refs https://chromium-review.googlesource.com/c/v8/v8/+/2718147 |
| 7 | + |
| 8 | +Fixes an issue where Node.js would try to call SetClassName on a |
| 9 | +FunctionTemplate twice in some cases. The above CL made it so that |
| 10 | +V8 CHECKs when this occurs. It is fixed by ensuring SetClassName |
| 11 | +is only called once. |
| 12 | + |
| 13 | +This should be upstreamed. |
| 14 | + |
| 15 | +diff --git a/src/histogram.cc b/src/histogram.cc |
| 16 | +index 3a3228ddc9eb6b53efc0721466479a9f62cd8967..175a67840348ca507d6e8b29835e5ab3b6d3e71a 100644 |
| 17 | +--- a/src/histogram.cc |
| 18 | ++++ b/src/histogram.cc |
| 19 | +@@ -340,8 +340,9 @@ void HistogramBase::RegisterExternalReferences( |
| 20 | + } |
| 21 | + |
| 22 | + void HistogramBase::Initialize(Environment* env, Local<Object> target) { |
| 23 | +- SetConstructorFunction( |
| 24 | +- env->context(), target, "Histogram", GetConstructorTemplate(env)); |
| 25 | ++ SetConstructorFunction(env->context(), target, "Histogram", |
| 26 | ++ GetConstructorTemplate(env), |
| 27 | ++ SetConstructorFunctionFlag::NONE); |
| 28 | + } |
| 29 | + |
| 30 | + BaseObjectPtr<BaseObject> HistogramBase::HistogramTransferData::Deserialize( |
| 31 | +@@ -367,6 +368,7 @@ Local<FunctionTemplate> IntervalHistogram::GetConstructorTemplate( |
| 32 | + Isolate* isolate = env->isolate(); |
| 33 | + tmpl = NewFunctionTemplate(isolate, nullptr); |
| 34 | + tmpl->Inherit(HandleWrap::GetConstructorTemplate(env)); |
| 35 | ++ tmpl->SetClassName(OneByteString(isolate, "Histogram")); |
| 36 | + tmpl->InstanceTemplate()->SetInternalFieldCount( |
| 37 | + HistogramBase::kInternalFieldCount); |
| 38 | + SetProtoMethodNoSideEffect(isolate, tmpl, "count", GetCount); |
| 39 | +diff --git a/src/node_messaging.cc b/src/node_messaging.cc |
| 40 | +index f88270fc75de91610a973c0649e1bc699c3e014d..e47f7a597a6ca0cfd71fec1e42f0fbb75cb539c7 100644 |
| 41 | +--- a/src/node_messaging.cc |
| 42 | ++++ b/src/node_messaging.cc |
| 43 | +@@ -1467,13 +1467,16 @@ static void InitMessaging(Local<Object> target, |
| 44 | + t->Inherit(BaseObject::GetConstructorTemplate(env)); |
| 45 | + t->InstanceTemplate()->SetInternalFieldCount( |
| 46 | + JSTransferable::kInternalFieldCount); |
| 47 | +- SetConstructorFunction(context, target, "JSTransferable", t); |
| 48 | ++ t->SetClassName(OneByteString(isolate, "JSTransferable")); |
| 49 | ++ SetConstructorFunction(context, target, "JSTransferable", t, |
| 50 | ++ SetConstructorFunctionFlag::NONE); |
| 51 | + } |
| 52 | + |
| 53 | + SetConstructorFunction(context, |
| 54 | + target, |
| 55 | + env->message_port_constructor_string(), |
| 56 | +- GetMessagePortConstructorTemplate(env)); |
| 57 | ++ GetMessagePortConstructorTemplate(env), |
| 58 | ++ SetConstructorFunctionFlag::NONE); |
| 59 | + |
| 60 | + // These are not methods on the MessagePort prototype, because |
| 61 | + // the browser equivalents do not provide them. |
0 commit comments