Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Segfault in AllocateJSPromise after upgrading to Electron 3 #19372

Closed

Description

@nathansobo

We're experiencing a new render process crash that seems to correlate with the upgrade to Electron 3. It originates from AllocateJSPromise within V8.

Observed by @rafeca on macOS while using the app (See gist for details):

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   libnode.dylib                 	0x0000000110212e93 v8::internal::Heap::AllocateJSPromise(v8::internal::JSFunction*, v8::internal::PretenureFlag) + 83 (heap.cc:3405)
1   libnode.dylib                 	0x00000001106dba3a v8::internal::Factory::NewJSPromiseWithoutHook(v8::internal::PretenureFlag) + 122 (factory.cc:3130)
2   libnode.dylib                 	0x00000001106dbc8f v8::internal::Factory::NewJSPromise(v8::internal::PretenureFlag) + 15 (factory.cc:3137)
3   libnode.dylib                 	0x000000011015e864 v8::Promise::Resolver::New(v8::Local<v8::Context>) + 340 (api.cc:7297)
4   libnode.dylib                 	0x000000010fdacb4d node::util::CreatePromise(v8::FunctionCallbackInfo<v8::Value> const&) + 29 (node_util.cc:147)
5   libnode.dylib                 	0x00000001102b7dd4 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo*) + 516 (api-arguments.cc:30)
6   libnode.dylib                 	0x000000011030a352 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) + 578 (builtins-api.cc:110)
7   libnode.dylib                 	0x0000000110309a3c v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) + 252
8   ???                           	0x00001e8d8288427d 0 + 33593129190013

Observed by @nathansobo and @as-cii in a VM running on @as-cii's machine while running render process tests:

Activity

  1. added
    electron-3
    on May 20, 2019
  2. nornagon commented on May 20, 2019

    @nornagon

    What electron version?

  3. Arcanemagus commented on May 20, 2019

    @Arcanemagus
    Contributor

    This was from Electron 3.1.9.

  4. nathansobo commented on May 21, 2019

    @nathansobo
    ContributorAuthor

    One interesting idea pointed out by @MarshallOfSound is that a limited number of code paths pass through Node's util::CreatePromise helper, defined here. I tried monkey-patching process.binding('util'), but the built-in Node modules that rely on this helper all capture it in their closure scope before I can run the monkey-patching code. But if we can somehow figure out where this function is getting called in our test suite, it might give us a hint as to the origin of the crash in our application JS. I'm not sure if that involves building our own version of Electron and injecting a console.trace or exception, or if there's an easier approach.

  5. MarshallOfSound commented on May 21, 2019

    @MarshallOfSound

    @nathansobo As that is being called from JS, you should be able to launch the inspector and add a breakpoint in that method to see when it gets called.

  6. as-cii commented on May 21, 2019

    @as-cii
    Contributor

    After merging upstream changes from Axosoft/nsfw, I am still able to reproduce this crash, even though AllocateJSPromise doesn't show up anymore:

    Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
    0   ???                           	0x0000024a0e27cd74 0 + 2517088324980
    1   ???                           	0x0000024a0e28d886 0 + 2517088393350
    2   ???                           	0x0000024a0e26dfda 0 + 2517088264154
    3   ???                           	0x0000024a0dd2a055 0 + 2517082742869
    4   ???                           	0x0000024a0dd09701 0 + 2517082609409
    5   libnode.dylib                 	0x000000010c009ed1 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling, v8::internal::Execution::Target) + 673 (execution.cc:153)
    6   libnode.dylib                 	0x000000010bfe8cf8 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>*) + 152 (execution.cc:200)
    7   libnode.dylib                 	0x000000010ba9d496 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 550 (api.cc:5089)
    8   libnode.dylib                 	0x000000010b69af15 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 261 (node.cc:750)
    9   libnode.dylib                 	0x000000010b67b45a node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) + 122 (async_wrap.cc:714)
    10  libnode.dylib                 	0x000000010b707ba9 node::(anonymous namespace)::TimerWrap::OnTimeout(uv_timer_s*) + 169 (timer_wrap.cc:147)
    11  libnode.dylib                 	0x000000010b58b3fa uv__run_timers + 58 (timer.c:155)
    12  libnode.dylib                 	0x000000010b58049b uv_run + 91 (core.c:360)
    13  com.github.electron.framework 	0x0000000106af720c atom::NodeBindings::UvRunOnce() + 172 (node_bindings.cc:335)
    14  com.github.electron.framework 	0x0000000106a63f4a void base::internal::FunctorTraits<void (atom::api::BrowserWindow::*)(), void>::Invoke<base::WeakPtr<atom::api::BrowserWindow> const&>(void (atom::api::BrowserWindow::*)(), base::WeakPtr<atom::api::BrowserWindow> const&&&) + 42 (bind_internal.h:447)
    15  com.github.electron.framework 	0x0000000106a63f18 void base::internal::InvokeHelper<true, void>::MakeItSo<void (atom::api::BrowserWindow::* const&)(), base::WeakPtr<atom::api::BrowserWindow> const&>(void (atom::api::BrowserWindow::* const&&&)(), base::WeakPtr<atom::api::BrowserWindow> const&&&) + 40 (bind_internal.h:553)
    16  com.github.electron.framework 	0x0000000106a63edc void base::internal::Invoker<base::internal::BindState<void (atom::api::BrowserWindow::*)(), base::WeakPtr<atom::api::BrowserWindow> >, void ()>::RunImpl<void (atom::api::BrowserWindow::* const&)(), std::__1::tuple<base::WeakPtr<atom::api::BrowserWindow> > const&, 0ul>(void (atom::api::BrowserWindow::* const&&&)(), std::__1::tuple<base::WeakPtr<atom::api::BrowserWindow> > const&&&, std::__1::integer_sequence<unsigned long, 0ul>) + 28 (bind_internal.h:604)
    17  com.github.electron.framework 	0x0000000106af77e4 base::internal::Invoker<base::internal::BindState<void (atom::NodeBindings::*)(), base::WeakPtr<atom::NodeBindings> >, void ()>::RunOnce(base::internal::BindStateBase*) + 20 (bind_internal.h:576)
    18  com.github.electron.framework 	0x0000000106bebc01 base::debug::TaskAnnotator::RunTask(char const*, base::PendingTask*) + 273 (task_annotator.cc:61)
    19  com.github.electron.framework 	0x0000000106c0d1ac base::MessageLoop::RunTask(base::PendingTask*) + 444 (message_loop.cc:395)
    20  com.github.electron.framework 	0x0000000106c0d918 base::MessageLoop::DoWork() + 424 (message_loop.cc:451)
    21  com.github.electron.framework 	0x0000000106ca3cca base::MessagePumpCFRunLoopBase::RunWork() + 42 (message_pump_mac.mm:462)
    22  com.github.electron.framework 	0x0000000106ca69fa base::mac::CallWithEHFrame(void () block_pointer) + 10
    23  com.github.electron.framework 	0x0000000106ca35ef base::MessagePumpCFRunLoopBase::RunWorkSource(void*) + 63 (message_pump_mac.mm:441)
    24  com.apple.CoreFoundation      	0x00007fff533bb083 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    25  com.apple.CoreFoundation      	0x00007fff533bb029 __CFRunLoopDoSource0 + 108
    26  com.apple.CoreFoundation      	0x00007fff5339e9eb __CFRunLoopDoSources0 + 195
    27  com.apple.CoreFoundation      	0x00007fff5339dfb5 __CFRunLoopRun + 1189
    28  com.apple.CoreFoundation      	0x00007fff5339d8be CFRunLoopRunSpecific + 455
    29  com.apple.HIToolbox           	0x00007fff5268996b RunCurrentEventLoopInMode + 292
    30  com.apple.HIToolbox           	0x00007fff526896a5 ReceiveNextEventCommon + 603
    31  com.apple.HIToolbox           	0x00007fff52689436 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    32  com.apple.AppKit              	0x00007fff50a23987 _DPSNextEvent + 965
    33  com.apple.AppKit              	0x00007fff50a2271f -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
    34  com.apple.AppKit              	0x00007fff50a1c83c -[NSApplication run] + 699
    35  com.github.electron.framework 	0x0000000106ca442c base::MessagePumpNSApplication::DoRun(base::MessagePump::Delegate*) + 300 (message_pump_mac.mm:831)
    36  com.github.electron.framework 	0x0000000106ca310e base::MessagePumpCFRunLoopBase::Run(base::MessagePump::Delegate*) + 110 (message_pump_mac.mm:192)
    37  com.github.electron.framework 	0x0000000106c32075 base::RunLoop::Run() + 53 (run_loop.cc:139)
    38  com.github.electron.framework 	0x00000001070fbc50 content::BrowserMainLoop::MainMessageLoopRun() + 192 (browser_main_loop.cc:1645)
    39  com.github.electron.framework 	0x00000001070fba80 content::BrowserMainLoop::RunMainMessageLoopParts() + 64 (browser_main_loop.cc:1108)
    40  com.github.electron.framework 	0x0000000107126f32 content::BrowserMainRunnerImpl::Run() + 18 (browser_main_runner.cc:161)
    41  com.github.electron.framework 	0x00000001070f7d89 content::BrowserMain(content::MainFunctionParams const&) + 233 (browser_main.cc:46)
    42  com.github.electron.framework 	0x0000000106ded719 content::ContentMainRunnerImpl::Run() + 377 (content_main_runner.cc:703)
    43  com.github.electron.framework 	0x0000000108aa8342 service_manager::Main(service_manager::MainParams const&) + 2418 (main.cc:453)
    44  com.github.electron.framework 	0x0000000106dec334 content::ContentMain(content::ContentMainParams const&) + 68 (content_main.cc:19)
    45  com.github.electron.framework 	0x00000001069ce4c4 AtomMain + 68 (atom_library_main.mm:23)
    46  com.github.atom               	0x00000001069c4e0b main + 43 (atom_main.cc:212)
    47  libdyld.dylib                 	0x00007fff7f2cc3d5 start + 1
    
  7. MarshallOfSound commented on May 21, 2019

    @MarshallOfSound

    @as-cii That looks like a different stack trace to the one @nathansobo posted above, yours has no mention of node promise util

  8. as-cii commented on May 21, 2019

    @as-cii
    Contributor

    @MarshallOfSound Correct, but I think that has to do with the fact that we upgraded one of our dependencies to not use promisify anymore and now the crash is happening in JavaScript itself (possibly by creating a JS Promise via new Promise()).

    Is it possible that a native module is using some V8's APIs in a weird/deprecated way (e.g., by not using AsyncResource correctly or whatnot) and then subsequent attempts to create Promises (or interacting with the async context in any way) generates an exception?

  9. MarshallOfSound commented on May 21, 2019

    @MarshallOfSound

    Is it possible that a native module is using some V8's APIs in a weird/deprecated way (e.g., by not using AsyncResource correctly or whatnot) and then subsequent attempts to create Promises (or interacting with the async context in any way) generates an exception?

    Possible, but also unlikely, without knowing where it's crashing in the native module it's hard to say

  10. nathansobo commented on May 21, 2019

    @nathansobo
    ContributorAuthor

    @as-cii I commented out the code that watches the config file on the main process and encountered this crash on the render process on d5ee4ba when running the nsfw test suite with the nsfw repository open in Atom.

    Thread 0 Crashed:: CrRendererMain  Dispatch queue: com.apple.main-thread
    0   ???                           	0x00000043fdee5ae4 0 + 292023065316
    1   ???                           	0x00000043fd8acc77 0 + 292016540791
    2   ???                           	0x00000043fd8a5263 0 + 292016509539
    3   ???                           	0x00000043fd8e537c 0 + 292016771964
    4   ???                           	0x00000043fded8a3b 0 + 292023011899
    5   ???                           	0x00000043fd8acc77 0 + 292016540791
    6   ???                           	0x00000043fdef5328 0 + 292023128872
    7   ???                           	0x00000043fdecd235 0 + 292022964789
    8   ???                           	0x00000043fd8acc77 0 + 292016540791
    9   ???                           	0x00000043fd8acc77 0 + 292016540791
    10  ???                           	0x00000043fd8a5263 0 + 292016509539
    11  ???                           	0x00000043fde46793 0 + 292022413203
    12  ???                           	0x00000043fd8a5263 0 + 292016509539
    13  ???                           	0x00000043fde76c90 0 + 292022611088
    14  ???                           	0x00000043fd8acc77 0 + 292016540791
    15  ???                           	0x00000043fdeb2968 0 + 292022856040
    16  ???                           	0x00000043fd8a5263 0 + 292016509539
    17  ???                           	0x00000043fd8acc77 0 + 292016540791
    18  ???                           	0x00000043fde466d2 0 + 292022413010
    19  ???                           	0x00000043fd8acc77 0 + 292016540791
    20  ???                           	0x00000043fd8acc77 0 + 292016540791
    21  ???                           	0x00000043fde795d4 0 + 292022621652
    22  ???                           	0x00000043fd8acc77 0 + 292016540791
    23  ???                           	0x00000043fde7ae93 0 + 292022627987
    24  ???                           	0x00000043fd8aa055 0 + 292016529493
    25  ???                           	0x00000043fd889701 0 + 292016396033
    26  libnode.dylib                 	0x0000000108968ed1 0x107ecd000 + 11124433
    27  libnode.dylib                 	0x0000000108947cf8 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>*) + 152
    28  libnode.dylib                 	0x00000001083fc496 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) + 550
    29  libnode.dylib                 	0x0000000107ff9f15 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 261
    30  libnode.dylib                 	0x0000000107ffa1bd node::MakeCallback(v8::Isolate*, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) + 109
    31  nsfw.node                     	0x00000001144667b9 Nan::Callback::Call_(v8::Isolate*, v8::Local<v8::Object>, int, v8::Local<v8::Value>*, Nan::AsyncResource*) const + 117 (v8.h:364)
    32  nsfw.node                     	0x0000000114464c33 NSFW::fireEventCallback(uv_async_s*) + 1415 (NSFW.cpp:98)
    33  libnode.dylib                 	0x0000000107edf16f 0x107ecd000 + 74095
    34  libnode.dylib                 	0x0000000107eee6f7 0x107ecd000 + 136951
    35  libnode.dylib                 	0x0000000107edf4d8 uv_run + 152
    36  com.github.electron.framework 	0x000000010bd8d20c atom::NodeBindings::UvRunOnce() + 172
    37  com.github.electron.framework 	0x000000010bcf9f4a 0x10bc62000 + 622410
    38  com.github.electron.framework 	0x000000010bcf9f18 0x10bc62000 + 622360
    39  com.github.electron.framework 	0x000000010bcf9edc 0x10bc62000 + 622300
    40  com.github.electron.framework 	0x000000010bd8d7e4 base::internal::Invoker<base::internal::BindState<void (atom::NodeBindings::*)(), base::WeakPtr<atom::NodeBindings> >, void ()>::RunOnce(base::internal::BindStateBase*) + 20
    41  com.github.electron.framework 	0x000000010be81c01 0x10bc62000 + 2227201
    42  com.github.electron.framework 	0x000000010e403e1f 0x10bc62000 + 41557535
    43  com.github.electron.framework 	0x000000010be81c01 0x10bc62000 + 2227201
    44  com.github.electron.framework 	0x000000010bea31ac 0x10bc62000 + 2363820
    45  com.github.electron.framework 	0x000000010bea3918 0x10bc62000 + 2365720
    46  com.github.electron.framework 	0x000000010bf39cca 0x10bc62000 + 2981066
    47  com.github.electron.framework 	0x000000010bf3c9fa 0x10bc62000 + 2992634
    48  com.github.electron.framework 	0x000000010bf395ef 0x10bc62000 + 2979311
    49  com.apple.CoreFoundation      	0x00007fff451585e3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    50  com.apple.CoreFoundation      	0x00007fff45158589 __CFRunLoopDoSource0 + 108
    51  com.apple.CoreFoundation      	0x00007fff4513bf3b __CFRunLoopDoSources0 + 195
    52  com.apple.CoreFoundation      	0x00007fff4513b505 __CFRunLoopRun + 1189
    53  com.apple.CoreFoundation      	0x00007fff4513ae0e CFRunLoopRunSpecific + 455
    54  com.apple.Foundation          	0x00007fff47391a9f -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 280
    55  com.github.electron.framework 	0x000000010bf3a1de 0x10bc62000 + 2982366
    56  com.github.electron.framework 	0x000000010bf3910e 0x10bc62000 + 2978062
    57  com.github.electron.framework 	0x000000010bec8075 0x10bc62000 + 2515061
    58  com.github.electron.framework 	0x000000010c84377d 0x10bc62000 + 12457853
    59  com.github.electron.framework 	0x000000010c083719 0x10bc62000 + 4331289
    60  com.github.electron.framework 	0x000000010dd3e342 0x10bc62000 + 34456386
    61  com.github.electron.framework 	0x000000010c082334 0x10bc62000 + 4326196
    62  com.github.electron.framework 	0x000000010bc644c4 AtomMain + 68
    63  com.github.atom.helper        	0x0000000107d92e0b main + 43
    64  libdyld.dylib                 	0x00007fff715af3d5 start + 1
    

    This seems to rule out nsfw's use of a deprecated code path to call back into JS as the cause of the crashes, since this version of Atom depends on an nsfw that includes your changes from fix-deprecations branch.

  11. nathansobo commented on May 21, 2019

    @nathansobo
    ContributorAuthor

    In bdf6b17, I hacked in some changes that seem to eliminate crashes of both the render process and the main process. We eliminate polling of the config file in the main process and process nsfw events in a process.nextTick callback. It's still worrisome that we don't really understand why these changes fix the crashes, however.

  12. self-assigned this
    on May 21, 2019
  13. nathansobo commented on May 22, 2019

    @nathansobo
    ContributorAuthor

    Nevermind. I encountered a render process crash after running the nsfw tests for a bit longer yesterday. Similar stack trace to those previously posted. The changes in bdf6b17 are not the solution.

  14. as-cii commented on May 23, 2019

    @as-cii
    Contributor

    Yesterday, we discovered that not using snapshots made the issue impossible to reproduce via the nsfw tests. That pushed me to investigate what could be possibly going wrong when running mksnapshot and, after some spelunking in the Electron codebase, I discovered electron/electron#18420.

    The good news is that the Electron team is working on releasing a new version that doesn't exhibit this behavior, and we only need a small tweak on our side to finally ship Atom on Electron 3.

    Stay tuned for an update on this.

  15. lock commented on Nov 26, 2019

    @lock

    This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

  16. locked as resolved and limited conversation to collaborators on Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

crashelectron-3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions