Skip to content

electron crash when using node vm #25888

Closed

Description

@iron-man-forever

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    9.3.1
  • Operating System:
    Windows 10 (1904)

Expected Behavior

print error on dev devtools

Actual Behavior

electron crash

To Reproduce

1: git clone https://github.com/electron/electron-quick-start
2: cd electron-quick-start
3: Install dependencies
4: npm install
5: add nodeintegration=true webPreferences(main.js)

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true
    }
  })

5: add script to renderer.js

const vm = require('vm');

const script = new vm.Script('console.log(asasa);');

const sandbox = {globalVar: 1, console: console};

const contetifiedSandbox = vm.createContext(sandbox);

const result = script.runInContext(contetifiedSandbox);

Screenshots

image

Additional Information

Activity

  1. self-assigned this
    on Oct 12, 2020
  2. codebytere commented on Oct 13, 2020

    @codebytere
    Member

    Stacktrace:

    Received signal 11 <unknown> 000000000000
    
    0   Electron Framework                  0x000000011ef09cc9 base::debug::CollectStackTrace(void**, unsigned long) + 9
    
    1   Electron Framework                  0x000000011ee04663 base::debug::StackTrace::StackTrace() + 19
    
    2   Electron Framework                  0x000000011ef09b91 base::debug::(anonymous namespace)::StackDumpSignalHandler(int, __siginfo*, void*) + 2385
    
    3   libsystem_platform.dylib            0x00007fff6adfe5fd _sigtramp + 29
    
    4   ???                                 0x0000000000000000 0x0 + 0
    
    5   Electron Framework                  0x000000012172ca5c blink::WorldSafeV8ReferenceInternal::MaybeCheckCreationContextWorld(blink::DOMWrapperWorld const&, v8::Local<v8::Value>) + 60
    
    6   Electron Framework                  0x000000012171f184 blink::WorldSafeV8Reference<v8::Value>::WorldSafeV8Reference(v8::Isolate*, v8::Local<v8::Value>) + 228
    
    7   Electron Framework                  0x000000012171ba87 blink::V8Initializer::MessageHandlerInMainThread(v8::Local<v8::Message>, v8::Local<v8::Value>) + 439
    
    8   Electron Framework                  0x000000011bccda5e v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>) + 846
    
    9   Electron Framework                  0x000000011bccd36c v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>) + 1660
    
    10  Electron Framework                  0x000000011bcb5e68 v8::internal::Isolate::ReportPendingMessages() + 1352
    
    11  Electron Framework                  0x000000011bc908ec v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) + 2812
    
    12  Electron Framework                  0x000000011bc8fddb v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) + 107
    
    13  Electron Framework                  0x000000011ba47a15 v8::Script::Run(v8::Local<v8::Context>) + 917
    
    14  Electron Framework                  0x000000012172260c blink::V8ScriptRunner::RunCompiledScript(v8::Isolate*, v8::Local<v8::Script>, blink::ExecutionContext*) + 1420
    
    15  Electron Framework                  0x0000000121722a41 blink::V8ScriptRunner::CompileAndRunScript(v8::Isolate*, blink::ScriptState*, blink::ExecutionContext*, blink::ScriptSourceCode const&, blink::KURL const&, blink::SanitizeScriptErrors, blink::ScriptFetchOptions const&, blink::mojom::V8CacheOptions) + 577
    
    16  Electron Framework                  0x00000001216de3b0 blink::ScriptController::ExecuteScriptAndReturnValue(v8::Local<v8::Context>, blink::ScriptSourceCode const&, blink::KURL const&, blink::SanitizeScriptErrors, blink::ScriptFetchOptions const&) + 256
    
    17  Electron Framework                  0x00000001216df537 blink::ScriptController::EvaluateScriptInMainWorld(blink::ScriptSourceCode const&, blink::KURL const&, blink::SanitizeScriptErrors, blink::ScriptFetchOptions const&, blink::ScriptController::ExecuteScriptPolicy) + 231
    
    18  Electron Framework                  0x000000012306e9de blink::ClassicScript::RunScript(blink::LocalFrame*) + 110
    
    19  Electron Framework                  0x000000012308cc5a blink::PendingScript::ExecuteScriptBlockInternal(blink::Script*, blink::ScriptElementBase*, bool, bool, bool, base::TimeTicks, bool) + 442
    
    20  Electron Framework                  0x000000012308c9a8 blink::PendingScript::ExecuteScriptBlock(blink::KURL const&) + 408
    
    21  Electron Framework                  0x000000012308ed98 blink::ScriptLoader::PrepareScript(WTF::TextPosition const&, blink::ScriptLoader::LegacyTypeSupport) + 5096
    
    22  Electron Framework                  0x0000000123072873 blink::HTMLParserScriptRunner::ProcessScriptElementInternal(blink::Element*, WTF::TextPosition const&) + 451
    
    23  Electron Framework                  0x00000001230725d8 blink::HTMLParserScriptRunner::ProcessScriptElement(blink::Element*, WTF::TextPosition const&) + 104
    
    24  Electron Framework                  0x00000001228743f9 blink::HTMLDocumentParser::RunScriptsForPausedTreeBuilder() + 169
    
    25  Electron Framework                  0x0000000122875efa blink::HTMLDocumentParser::ProcessTokenizedChunkFromBackgroundParser(std::__1::unique_ptr<blink::HTMLDocumentParser::TokenizedChunk, std::__1::default_delete<blink::HTMLDocumentParser::TokenizedChunk> >, bool*) + 1738
    
    26  Electron Framework                  0x0000000122874238 blink::HTMLDocumentParser::PumpPendingSpeculations() + 1048
    
    27  Electron Framework                  0x0000000122878c9f blink::HTMLDocumentParser::ResumeParsingAfterPause() + 639
    
    28  Electron Framework                  0x0000000122879349 blink::HTMLDocumentParser::ExecuteScriptsWaitingForResources() + 329
    
    29  Electron Framework                  0x000000011d3936f1 WTF::ThreadCheckingCallbackWrapper<base::OnceCallback<void ()>, void ()>::Run() + 145
    
    30  Electron Framework                  0x000000011d3a157e blink::TaskHandle::Runner::Run(blink::TaskHandle const&) + 174
    
    31  Electron Framework                  0x000000011d3a1f25 base::internal::Invoker<base::internal::BindState<void (blink::TaskHandle::Runner::*)(blink::TaskHandle const&), base::WeakPtr<blink::TaskHandle::Runner>, blink::TaskHandle>, void ()>::RunOnce(base::internal::BindStateBase*) + 165
    
    32  Electron Framework                  0x000000011d3936f1 WTF::ThreadCheckingCallbackWrapper<base::OnceCallback<void ()>, void ()>::Run() + 145
    
    33  Electron Framework                  0x000000011ee99ecb base::TaskAnnotator::RunTask(char const*, base::PendingTask*) + 395
    
    34  Electron Framework                  0x000000011eeb8a67 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow*) + 519
    
    35  Electron Framework                  0x000000011eeb86c8 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() + 168
    
    36  Electron Framework                  0x000000011ef2a111 base::MessagePumpCFRunLoopBase::RunWork() + 65
    
    37  Electron Framework                  0x000000011ef1f492 base::mac::CallWithEHFrame(void () block_pointer) + 10
    
    38  Electron Framework                  0x000000011ef29adf base::MessagePumpCFRunLoopBase::RunWorkSource(void*) + 63
    
    39  CoreFoundation                      0x00007fff30b9ad52 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    
    40  CoreFoundation                      0x00007fff30b9acf1 __CFRunLoopDoSource0 + 103
    
    41  CoreFoundation                      0x00007fff30b9ab0b __CFRunLoopDoSources0 + 209
    
    42  CoreFoundation                      0x00007fff30b9983a __CFRunLoopRun + 927
    
    43  CoreFoundation                      0x00007fff30b98e3e CFRunLoopRunSpecific + 462
    
    44  Foundation                          0x00007fff332341c8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    
    45  Electron Framework                  0x000000011ef2aa51 base::MessagePumpNSRunLoop::DoRun(base::MessagePump::Delegate*) + 113
    
    46  Electron Framework                  0x000000011ef29603 base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*) + 131
    
    47  Electron Framework                  0x000000011eeb9273 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) + 355
    
    48  Electron Framework                  0x000000011ee6d405 base::RunLoop::Run() + 949
    
    49  Electron Framework                  0x00000001246f2faa content::RendererMain(content::MainFunctionParams const&) + 1370
    
    50  Electron Framework                  0x000000011d5fb6d1 content::ContentMainRunnerImpl::Run(bool) + 449
    
    51  Electron Framework                  0x000000011b42770e content::RunContentProcess(content::ContentMainParams const&, content::ContentMainRunner*) + 2782
    
    52  Electron Framework                  0x000000011b4277fc content::ContentMain(content::ContentMainParams const&) + 44
    
    53  Electron Framework                  0x0000000119569769 ElectronMain + 137
    
    54  Electron Helper (Renderer)          0x000000010eeb9b4e main + 430
    
    55  libdyld.dylib                       0x00007fff6ac05cc9 start + 1
    
    56  ???                                 0x0000000000000016 0x0 + 22
    
    [end of stack trace]
    
  3. iron-man-forever commented on Oct 13, 2020

    @iron-man-forever
    Author

    lt looks like the blink will check ContextWorld,but the context created by node not belong to main world context or isolate world context and worker world

  4. codebytere commented on Oct 13, 2020

    @codebytere
    Member

    @caihuan yep, exactly! popped up a PR to handle it :)

  5. iron-man-forever commented on Oct 14, 2020

    @iron-man-forever
    Author

    @caihuan yep, exactly! popped up a PR to handle it :)

    the pull request does not work w(゚Д゚)w on fix: ScriptState crash for non-Blink v8::Contexts #25910

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions