Skip to content

vm.compileFunction throws an RangeError when invoked with options.lineOffset < 0 #43207

Closed
@CathyKMeow

Description

@CathyKMeow

Version

v18.2.0

Platform

Linux localhost 5.17.0-rc7-asahi-next-20220310-5-2-ARCH #4 SMP PREEMPT Fri, 20 May 2022 00:28:08 +0000 aarch64 GNU/Linux

Subsystem

node:vm

What steps will reproduce the bug?

node -p 'vm.compileFunction("", [], { lineOffset: -1 })'

How often does it reproduce? Is there a required condition?

Always, without conditions.

What is the expected behavior?

user@localhost:~$ node -p 'vm.compileFunction("", [], { lineOffset: -1 })'
[Function (anonymous)]

What do you see instead?

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=archarm
ID_LIKE=arch
BUILD_ID=rolling
ANSI_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-logo
user@localhost:~$ date
Wed May 25 10:54:30 PDT 2022
user@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions