Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 44f781d

Browse filesBrowse files
bnoordhuisofrobots
authored andcommitted
v8: warn in Template::Set() on improper use
The next major release will make it a fatal error to use non-primitive values in function templates and object templates. Print a warning that includes the C and JS stack trace to tell people to upgrade their add-ons. The C stack trace is only printed on platforms that support it (the BSDs, OS X and Linux+glibc.) The warning can be disabled with the new `--nowarn_template_set` flag. Refs: #6216 PR-URL: #6277 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b2f7c32 commit 44f781d
Copy full SHA for 44f781d

File tree

Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-0
lines changed
Open diff view settings
Collapse file

‎deps/v8/src/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api.cc
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,16 @@ void Template::Set(v8::Local<Name> name, v8::Local<Data> value,
10361036
i::Handle<i::FunctionTemplateInfo>::cast(templ)->set_do_not_cache(true);
10371037
}
10381038
}
1039+
if (i::FLAG_warn_template_set &&
1040+
value_obj->IsJSReceiver() &&
1041+
!value_obj->IsTemplateInfo()) {
1042+
base::OS::PrintError(
1043+
"(node) v8::%sTemplate::Set() with non-primitive values is deprecated\n"
1044+
"(node) and will stop working in the next major release.\n",
1045+
templ->IsFunctionTemplateInfo() ? "Function" : "Object");
1046+
isolate->PrintStack(stderr, i::Isolate::kPrintStackConcise);
1047+
base::DumpBacktrace();
1048+
}
10391049
// TODO(dcarney): split api to allow values of v8::Value or v8::TemplateInfo.
10401050
i::ApiNatives::AddDataProperty(isolate, templ, Utils::OpenHandle(*name),
10411051
value_obj,
Collapse file

‎deps/v8/src/flag-definitions.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/flag-definitions.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ struct MaybeBoolFlag {
172172
//
173173
#define FLAG FLAG_FULL
174174

175+
DEFINE_BOOL(warn_template_set, true,
176+
"warn on deprecated v8::Template::Set() use")
177+
175178
DEFINE_BOOL(experimental_extras, false,
176179
"enable code compiled in via v8_experimental_extra_library_files")
177180

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.