Skip to content

vm.compileFunction() aborts the process on values its own validation accepts #67366

Open

Description

@theosotr

Summary

vm.compileFunction() can abort with SIGABRT for some values of params and options.contextExtensions that
its own argument validation accepts. The simplest case:

require('vm').compileFunction('return 1', [], { contextExtensions: [null] });

Expected: TypeError

Environment

  • Node.js v26.13.0
  • Linux x86_64

Reproducer

require('vm').compileFunction('return 1', [], { contextExtensions: [null] });
node[...]: static void node::contextify::ContextifyFunction::CompileFunction(
    const FunctionCallbackInfo<Value> &) at ../src/node_contextify.cc:1476
#  Assertion failed: val->IsObject()

----- Native stack trace -----
 2: node::Assert(node::AssertionInfo const&)
 3: node::contextify::ContextifyFunction::CompileFunction(...)

----- JavaScript stack trace -----
1: internalCompileFunction (node:internal/vm:137:18)

or

const vm = require('vm');

let reads = 0;
const params = [];
Object.defineProperty(params, 0, {
  enumerable: true, configurable: true,
  get() { return ++reads <= 1 ? 'x' : 42; },
});

vm.compileFunction('return 1', params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions