You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vm.compileFunction throws an RangeError when invoked with options.lineOffset < 0 #43207
user@localhost:~$ node -p 'vm.compileFunction("", [], { lineOffset: -1 })'node:internal/validators:110 throw new ERR_OUT_OF_RANGE(name, `>= ${min} && < 4294967296`, value); ^RangeError [ERR_OUT_OF_RANGE]: The value of "options.lineOffset" is out of range. It must be >= 0 && < 4294967296. Received -1 at Object.compileFunction (node:vm:329:3) at [eval]:1:4 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:305:38) at node:internal/process/execution:76:19 at [eval]-wrapper:6:22 at evalScript (node:internal/process/execution:75:60) at node:internal/main/eval_string:27:3 { code: 'ERR_OUT_OF_RANGE'}Node.js v18.2.0
Additional information
script.runInContext, runInContext, etc. accept options.lineOffset < 0.
user@localhost:~$ cat /etc/os-release NAME="Arch Linux ARM"PRETTY_NAME="Arch Linux ARM"ID=archarmID_LIKE=archBUILD_ID=rollingANSI_COLOR="38;2;23;147;209"HOME_URL="https://archlinuxarm.org/"DOCUMENTATION_URL="https://archlinuxarm.org/wiki"SUPPORT_URL="https://archlinuxarm.org/forum"BUG_REPORT_URL="https://github.com/archlinuxarm/PKGBUILDs/issues"LOGO=archlinux-logouser@localhost:~$ dateWed May 25 10:54:30 PDT 2022user@localhost:~$ sudo pacman -Syu:: Synchronizing package databases... asahi is up to date core is up to date extra is up to date community is up to date alarm is up to date aur is up to date:: Starting full system upgrade...warning: rust: local (1:1.61.0-1.1) is newer than extra (1:1.61.0-1)warning: rust-src: local (1:1.61.0-1.1) is newer than extra (1:1.61.0-1) there is nothing to do
It seems like a better approach might be to support async function bodies in compileFunction instead?
Yes, but anyway we should support negative lineOffset. In most circumstances we add wrappers around the code, not remove parts of the code.
You can't expect
@bnoordhuis@devsnek So this question should support negative numbers? I'm happy to submit a pull request - internalCompileFunction method in the verification lineOffset parameter, validateUint32 to validateInt32 on the line, right?
@bnoordhuis After testing that 'lineOffset' supports negative numbers, stack failed to print the correct line number. For example, the following example passed the test
I'm not sure if this behavior meets expectations. If stack is changed to "Error: Sample Error\n at :0:7", the test will not pass. I'm not sure it makes sense to support negative numbers.
Activity
devsnek commentedon May 25, 2022
i think technically the bug here is that we allow negative numbers elsewhere.
CathyKMeow commentedon May 25, 2022
But IMO negative number should be allowed, actually.
Here's my use case:
devsnek commentedon May 25, 2022
It seems like a better approach might be to support async function bodies in
compileFunctioninstead?bnoordhuis commentedon May 26, 2022
Orthogonal issues? V8 deliberately supports negative line and column offsets, ergo, it seems reasonable to support them in node as well.
CathyKMeow commentedon May 26, 2022
Yes, but anyway we should support negative lineOffset. In most circumstances we add wrappers around the code, not remove parts of the code.
You can't expect
to work.
And, in the native part of
vm,node/src/node_contextify.cc
Line 1044 in a346572
node/src/node_contextify.cc
Line 1112 in a346572
node/deps/v8/include/v8-message.h
Line 65 in a346572
lineOffset is a signed int32.
sinkhaha commentedon May 24, 2023
@bnoordhuis @devsnek So this question should support negative numbers? I'm happy to submit a pull request - internalCompileFunction method in the verification lineOffset parameter, validateUint32 to validateInt32 on the line, right?
bnoordhuis commentedon May 24, 2023
@sinkhaha yes, I believe so.
sinkhaha commentedon May 25, 2023
@bnoordhuis After testing that 'lineOffset' supports negative numbers, stack failed to print the correct line number. For example, the following example passed the test
I'm not sure if this behavior meets expectations. If stack is changed to "Error: Sample Error\n at :0:7", the test will not pass. I'm not sure it makes sense to support negative numbers.
fhinkel commentedon Jan 28, 2024
Closed via #49855