-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm
: vm.compileFunction
does not support negative lineOffset
and columnOffset
#49848
Labels
confirmed-bug
Issues with confirmed bugs.
good first issue
Issues that are suitable for first-time contributors.
vm
Issues and PRs related to the vm subsystem.
Comments
(1) is a validation bug and probably also responsible for (2), see diff and PR welcome. Other parts of node do seem to be validating it correctly as an int32, just not lib/internal/vm.js. diff --git a/lib/internal/vm.js b/lib/internal/vm.js
index ba5e232466..111bab8621 100644
--- a/lib/internal/vm.js
+++ b/lib/internal/vm.js
@@ -13,10 +13,10 @@ const {
validateBoolean,
validateBuffer,
validateFunction,
+ validateInt32,
validateObject,
validateString,
validateStringArray,
- validateUint32,
} = require('internal/validators');
const {
ERR_INVALID_ARG_TYPE,
@@ -46,8 +46,8 @@ function internalCompileFunction(code, params, options) {
} = options;
validateString(filename, 'options.filename');
- validateUint32(columnOffset, 'options.columnOffset');
- validateUint32(lineOffset, 'options.lineOffset');
+ validateInt32(columnOffset, 'options.columnOffset');
+ validateInt32(lineOffset, 'options.lineOffset');
if (cachedData !== undefined)
validateBuffer(cachedData, 'options.cachedData');
validateBoolean(produceCachedData, 'options.produceCachedData'); |
bnoordhuis
added
confirmed-bug
Issues with confirmed bugs.
vm
Issues and PRs related to the vm subsystem.
labels
Sep 25, 2023
joyeecheung
added
the
good first issue
Issues that are suitable for first-time contributors.
label
Sep 25, 2023
Created PR. |
alexfernandez
pushed a commit
to alexfernandez/node
that referenced
this issue
Nov 1, 2023
PR-URL: nodejs#49855 Fixes: nodejs#49848 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
joyeecheung
pushed a commit
to joyeecheung/node
that referenced
this issue
Nov 25, 2023
PR-URL: nodejs#49855 Fixes: nodejs#49848 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
joyeecheung
pushed a commit
to joyeecheung/node
that referenced
this issue
Dec 1, 2023
PR-URL: nodejs#49855 Fixes: nodejs#49848 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
debadree25
pushed a commit
to debadree25/node
that referenced
this issue
Apr 15, 2024
PR-URL: nodejs#49855 Fixes: nodejs#49848 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
confirmed-bug
Issues with confirmed bugs.
good first issue
Issues that are suitable for first-time contributors.
vm
Issues and PRs related to the vm subsystem.
Version:
v20.6.1
; older versions are also affectedSubsystem
vm
Current issue:
The
vm.compileFunction
method in Node.js currently doesn't support negativelineOffset
andcolumnOffset
values.(2^31)-1
, causing it to become -2147483637 with the presence of overflow protection measures:Additional information:
The
vm.compileFunction
method in Node.js currently doesn't support negativelineOffset
andcolumnOffset
values. This is inconsistent with other methods such asvm.runInContext
,vm.runInNewContext
, andnew vm.Script()
, which do support negative values for these parameters.The underlying V8 engine also supports negative values for these parameters as indicated in the
ScriptOrigin
class:A common use case for the
lineOffset
option invm.compileFunction
is to shift lines in error tracebacks to support adding wrappers. Negative values enable the correct line number to be displayed in stack traces when wrapper code is added, while positive values would require part of the code to be removed to get a correct line number, which is not applicable in most scenarios. Hence, negative options are a primary use case that should be supported. An example use case is shown below:Possible solution:
Upon investigation, the cause of this issue can be traced back to this line in
lib/internal/vm.js
:node/lib/internal/vm.js
Line 50 in 448996c
A tested and effective solution is to change the
validateUint32
function tovalidateInt32
for thelineOffset
andcolumnOffset
parameters.The text was updated successfully, but these errors were encountered: