Skip to content
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.compileFunction results in an abort #56366

Open
zyscoder opened this issue Dec 26, 2024 · 1 comment
Open

vm.compileFunction results in an abort #56366

zyscoder opened this issue Dec 26, 2024 · 1 comment
Labels
confirmed-bug Issues with confirmed bugs. vm Issues and PRs related to the vm subsystem.

Comments

@zyscoder
Copy link

Version

v22.11.0

Platform

Linux u24vm 6.8.0-50-generic #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov  9 17:58:29 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

vm

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

vm = require('vm');
_454 = (new vm.Script('')).createCachedData();
_723 = {cachedData:_454,produceCachedData:true};
vm.compileFunction('',undefined,_723);

Then the node instance occurs an abort.

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

This abort can always be triggered following the steps above.

What is the expected behavior? Why is that the expected behavior?

If any error occurs, an exception or similar error-reporting stuff should be thrown, caught, and handled correctly. There is no reason to abort the whole node process.

What do you see instead?

 » node                                                                     
Welcome to Node.js v22.11.0.
Type ".help" for more information.
> vm = require('vm');
{
  Script: [class Script extends ContextifyScript],
  createContext: [Function: createContext],
  createScript: [Function: createScript],
  runInContext: [Function: runInContext],
  runInNewContext: [Function: runInNewContext],
  runInThisContext: [Function: runInThisContext],
  isContext: [Function: isContext],
  compileFunction: [Function: compileFunction],
  measureMemory: [Function: measureMemory],
  constants: [Object: null prototype] {
    USE_MAIN_CONTEXT_DEFAULT_LOADER: Symbol(vm_dynamic_import_main_context_default),
    DONT_CONTEXTIFY: Symbol(vm_context_no_contextify)
  }
}
> _454 = (new vm.Script('')).createCachedData();
<Buffer 28 06 de c0 74 fe da 79 00 00 00 00 f5 24 1e 1c ad 85 35 f2 30 01 00 00 00 00 00 00 00 00 00 00 01 20 54 03 24 07 b4 60 00 00 00 00 02 00 00 00 01 0c ... 286 more bytes>
> _723 = {cachedData:_454,produceCachedData:true};
{
  cachedData: <Buffer 28 06 de c0 74 fe da 79 00 00 00 00 f5 24 1e 1c ad 85 35 f2 30 01 00 00 00 00 00 00 00 00 00 00 01 20 54 03 24 07 b4 60 00 00 00 00 02 00 00 00 01 0c ... 286 more bytes>,
  produceCachedData: true
}
> vm.compileFunction('',undefined,_723);
FATAL ERROR: v8::ScriptCompiler::CreateCodeCacheForFunction Expected SharedFunctionInfo with wrapped source code
----- Native stack trace -----

 1: 0xe19ca5 node::OnFatalError(char const*, char const*) [node]
 2: 0x123f996 v8::Utils::ReportApiFailure(char const*, char const*) [node]
 3: 0x1248df7 v8::ScriptCompiler::CreateCodeCacheForFunction(v8::Local<v8::Function>) [node]
 4: 0xf610b8 node::contextify::ContextifyContext::CompileFunctionAndCacheResult(node::Environment*, v8::Local<v8::Context>, v8::ScriptCompiler::Source*, std::vector<v8::Local<v8::String>, std::allocator<v8::Local<v8::String> > >, std::vector<v8::Local<v8::Object>, std::allocator<v8::Local<v8::Object> > >, v8::ScriptCompiler::CompileOptions, bool, v8::Local<v8::Symbol>, node::errors::TryCatchScope const&) [node]
 5: 0xf62d2b node::contextify::ContextifyContext::CompileFunction(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: 0x7fca6940f5e2

----- JavaScript stack trace -----

1: internalCompileFunction (node:internal/vm:128:18)
2: compileFunction (node:vm:364:10)
3: REPL4:1:4
4: runInThisContext (node:vm:137:12)
5: defaultEval (node:repl:598:22)
6: bound (node:domain:433:15)
7: runBound (node:domain:444:12)
8: onLine (node:repl:927:10)
9: emit (node:events:530:35)
10: emit (node:domain:489:12)


[1]    1489272 IOT instruction (core dumped)  node

Additional information

No response

@targos targos added confirmed-bug Issues with confirmed bugs. vm Issues and PRs related to the vm subsystem. labels Dec 26, 2024
@targos
Copy link
Member

targos commented Dec 26, 2024

@nodejs/vm

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. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants