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

Unhandled c++ exception in keytar native module #111288

Closed
bpasero opened this issue Nov 25, 2020 · 4 comments
Closed

Unhandled c++ exception in keytar native module #111288

bpasero opened this issue Nov 25, 2020 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debt Code quality issues engineering VS Code - Build / issue tracking / etc. freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues integration-test-failure upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream
Milestone

Comments

@bpasero bpasero added important Issue identified as high-priority engineering VS Code - Build / issue tracking / etc. integration-test-failure electron-11-update labels Nov 25, 2020
@bpasero bpasero added the linux Issues with VS Code on Linux label Nov 25, 2020
@deepak1556
Copy link
Collaborator

Still an issue with keytar module, will have to use the debug version of the module to get a better idea. Unable to repro locally after many runs.

Operating system: Windows NT
                  10.0.14393 3630
CPU: amd64
     family 6 model 79 stepping 1
     2 CPUs

GPU: UNKNOWN

Crash reason:  Unhandled C++ Exception
Crash address: 0x7ffd47a24f38
Process uptime: 4 seconds

Thread 0 (crashed)
 0  KERNELBASE.dll!RaiseException + 0x68
    rax = 0x00007ff681eb1774   rdx = 0x0000000000000000
    rcx = 0x0000000000000000   rbx = 0x00007ffd2bb91ad0
    rsi = 0x000000aaf4efdb70   rdi = 0x000000aaf4efb620
    rbp = 0x000000aaf4efb5d0   rsp = 0x000000aaf4efb490
     r8 = 0x0000000000000000    r9 = 0x0000000000000000
    r10 = 0x0000000000000000   r11 = 0x0000000000000000
    r12 = 0x000000aaf4efb7a0   r13 = 0x0000000000000000
    r14 = 0x000000aaf4efca78   r15 = 0x0000000000000000
    rip = 0x00007ffd47a24f38
    Found by: given as instruction pointer in context
 1  keytar.node + 0xa319
    rbx = 0x00007ffd2bb91ad0   rbp = 0x000000aaf4efb5d0
    rsp = 0x000000aaf4efb570   r12 = 0x000000aaf4efb7a0
    r13 = 0x0000000000000000   r14 = 0x000000aaf4efca78
    r15 = 0x0000000000000000   rip = 0x00007ffd2bb7a319
    Found by: call frame info
 2  keytar.node + 0x1ad0
    rbp = 0x000000aaf4efdf10   rsp = 0x000000aaf4efb5e0
    rip = 0x00007ffd2bb71ad0
    Found by: previous frame's frame pointer
 3  0x1cd4d5b6440
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efdf20
    rip = 0x000001cd4d5b6440
    Found by: previous frame's frame pointer
 4  keytar.node + 0x24cd
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efdf50
    rip = 0x00007ffd2bb724cd
    Found by: stack scanning
 5  Code - Insiders.exe!v8::HandleScope::CreateHandle(v8::internal::Isolate *,unsigned __int64) [api.cc : 1148 + 0xf]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efdf70
    rip = 0x00007ff681b2a4f9
    Found by: stack scanning
 6  Code - Insiders.exe!node::AsyncResource::CallbackScope::CallbackScope(node::AsyncResource *) [async_resource.cc : 70 + 0x15]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efdfb0
    rip = 0x00007ff684a2663d
    Found by: call frame info
 7  Code - Insiders.exe!static void `anonymous namespace'::uvimpl::Work::AfterThreadPoolWork(int) [node_api.cc : 928 + 0x51]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efe000
    rip = 0x00007ff683e3c8fa
    Found by: call frame info
 8  Code - Insiders.exe!uv__work_done [threadpool.c : 313 + 0x3]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efe0e0
    rip = 0x00007ff683e57ca8
    Found by: call frame info
 9  Code - Insiders.exe!uv_run [core.c : 524 + 0x8d]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4efe140
    rip = 0x00007ff68329f549
    Found by: call frame info
10  Code - Insiders.exe!node::Environment::CleanupHandles() [env.cc : 559 + 0xa]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff200
    rip = 0x00007ff683266e71
    Found by: call frame info
11  Code - Insiders.exe!node::Environment::RunCleanup() [env.cc : 604 + 0x5]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff260
    rip = 0x00007ff6832671a6
    Found by: call frame info
12  Code - Insiders.exe!node::FreeEnvironment(node::Environment *) [environment.cc : 333 + 0x5]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff330
    rip = 0x00007ff68324f8ad
    Found by: call frame info
13  Code - Insiders.exe!electron::ElectronBrowserMainParts::PostMainMessageLoopRun() [electron_browser_main_parts.cc : 587 + 0x19]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff360
    rip = 0x00007ff68075b12f
    Found by: call frame info
14  Code - Insiders.exe!content::BrowserMainLoop::ShutdownThreadsAndCleanUp() [browser_main_loop.cc : 1057 + 0x6]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff3d0
    rip = 0x00007ff6813b770d
    Found by: call frame info
15  Code - Insiders.exe!content::BrowserMainRunnerImpl::Shutdown() [browser_main_runner_impl.cc : 178 + 0x5]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff4f0
    rip = 0x00007ff6813b91dc
    Found by: call frame info
16  Code - Insiders.exe!content::BrowserMain(content::MainFunctionParams const &) [browser_main.cc : 49 + 0x6]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff590
    rip = 0x00007ff6813b49a0
    Found by: call frame info
17  Code - Insiders.exe!content::ContentMainRunnerImpl::RunServiceManager(content::MainFunctionParams &,bool) [content_main_runner_impl.cc : 979 + 0x47]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff630
    rip = 0x00007ff68129a789
    Found by: call frame info
18  Code - Insiders.exe!content::ContentMainRunnerImpl::Run(bool) [content_main_runner_impl.cc : 858 + 0x10]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff730
    rip = 0x00007ff68129a39c
    Found by: call frame info
19  Code - Insiders.exe!content::RunContentProcess(content::ContentMainParams const &,content::ContentMainRunner *) [content_main.cc : 373 + 0xd]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff7d0
    rip = 0x00007ff6812992d4
    Found by: call frame info
20  Code - Insiders.exe!content::ContentMain(content::ContentMainParams const &) [content_main.cc : 399 + 0x8]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4eff9e0
    rip = 0x00007ff6812995fd
    Found by: call frame info
21  Code - Insiders.exe!wWinMain [electron_main.cc : 219 + 0x8]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4effa30
    rip = 0x00007ff680691506
    Found by: call frame info
22  Code - Insiders.exe!static int __scrt_common_main_seh() [exe_common.inl : 288 + 0x21]
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4effbe0
    rip = 0x00007ff6864458a2
    Found by: call frame info
23  KERNEL32.DLL!BaseThreadInitThunk + 0x14
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4effc20
    rip = 0x00007ffd480a84d4
    Found by: call frame info
24  ntdll.dll!RtlUserThreadStart + 0x21
    rbp = 0x000000aaf4efe020   rsp = 0x000000aaf4effc50
    rip = 0x00007ffd4a891791
    Found by: call frame info

@deepak1556 deepak1556 removed important Issue identified as high-priority linux Issues with VS Code on Linux labels Nov 25, 2020
@deepak1556
Copy link
Collaborator

deepak1556 commented Nov 25, 2020

Minimal repro https://gist.github.com/deepak1556/bcfb70eb4ad93e6e738a99772f145498 based on suggestion from @alexdima .

Steps:

  • Run with debug build of keytar
  • Quit the app while the log is printing
  • Stack trace below.

So the issue is exactly what we thought, aync work being processed after the node env was torn down and the exception thrown by napi wrapper is not handled.

Application Specific Information:
terminating with uncaught exception of type Napi::Error: 
abort() called

Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib        	0x00007fff202fe462 __pthread_kill + 10
1   libsystem_pthread.dylib       	0x00007fff2032c610 pthread_kill + 263
2   libsystem_c.dylib             	0x00007fff2027f720 abort + 120
3   libc++abi.dylib               	0x00007fff202f1418 abort_message + 231
4   libc++abi.dylib               	0x00007fff202e2a65 demangling_terminate_handler() + 242
5   libobjc.A.dylib               	0x00007fff201d89b9 _objc_terminate() + 104
6   libc++abi.dylib               	0x00007fff202f0847 std::__terminate(void (*)()) + 8
7   libc++abi.dylib               	0x00007fff202f3167 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27
8   libc++abi.dylib               	0x00007fff202f312e __cxa_throw + 113
9   keytar.node                   	0x000000010f61e910 Napi::Error::ThrowAsJavaScriptException() const + 272 (napi-inl.h:2323)
10  keytar.node                   	0x000000010f61e6e4 napi_value__* Napi::details::WrapCallback<Napi::AsyncWorker::OnWorkComplete(Napi::Env, napi_status)::'lambda'()>(Napi::AsyncWorker::OnWorkComplete(Napi::Env, napi_status)::'lambda'()) + 84 (napi-inl.h:75)
11  keytar.node                   	0x000000010f61c774 Napi::AsyncWorker::OnWorkComplete(Napi::Env, napi_status) + 84 (napi-inl.h:4325)
12  keytar.node                   	0x000000010f61e0b4 Napi::AsyncWorker::OnAsyncWorkComplete(napi_env__*, napi_status, void*) + 68 (napi-inl.h:4320)
13  com.github.Electron.framework 	0x00000001097cd1a6 napi_ref_threadsafe_function + 2262
14  com.github.Electron.framework 	0x0000000106a5e6d8 uv_random + 1432
15  com.github.Electron.framework 	0x0000000106a62360 uv_async_send + 944
16  com.github.Electron.framework 	0x0000000106a7393c uv_free_interface_addresses + 2156
17  com.github.Electron.framework 	0x0000000106a627d7 uv_run + 375
18  com.github.Electron.framework 	0x00000001097a9625 node::EmitAsyncDestroy(node::Environment*, node::async_context) + 229509
19  com.github.Electron.framework 	0x00000001097a98f0 node::EmitAsyncDestroy(node::Environment*, node::async_context) + 230224
20  com.github.Electron.framework 	0x000000010976ecfe node::FreeEnvironment(node::Environment*) + 14
21  com.github.Electron.framework 	0x0000000106b39943 ElectronInitializeICUandStartNode + 809411
22  com.github.Electron.framework 	0x000000010784f589 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 2225897
23  com.github.Electron.framework 	0x0000000107850c44 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 2231716
24  com.github.Electron.framework 	0x000000010784c655 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 2213813
25  com.github.Electron.framework 	0x0000000107816ec1 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 1994785
26  com.github.Electron.framework 	0x0000000107816be6 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) + 1994054
27  com.github.Electron.framework 	0x000000010705a1ee ElectronInitializeICUandStartNode + 6185582
28  com.github.Electron.framework 	0x000000010705a6f2 ElectronInitializeICUandStartNode + 6186866
29  com.github.Electron.framework 	0x0000000106a73f48 ElectronMain + 136
30  com.github.Electron           	0x0000000106a275bd 0x106a23000 + 17853
31  libdyld.dylib                 	0x00007fff20347631 start + 1

@deepak1556 deepak1556 changed the title Linux: integration tests core dump Unhandled c++ exception in keytar native module Nov 25, 2020
@deepak1556 deepak1556 added freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues and removed electron-11-update labels Nov 25, 2020
deepak1556 added a commit that referenced this issue Nov 26, 2020
@deepak1556 deepak1556 added upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream labels Dec 16, 2020
@joaomoreno joaomoreno added this to the January 2021 milestone Jan 7, 2021
@bpasero
Copy link
Member Author

bpasero commented Feb 17, 2021

#116852 adds a --disable-keytar to our integration tests. Let's see how that goes.

@deepak1556 deepak1556 modified the milestones: February 2021, March 2021 Feb 18, 2021
@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Mar 26, 2021
@deepak1556 deepak1556 removed this from the March 2021 milestone Mar 26, 2021
@deepak1556
Copy link
Collaborator

Upstream issue is now addressed via nodejs/node-addon-api#975 , will try to verify in debt week.

@deepak1556 deepak1556 added this to the July 2021 milestone Jun 22, 2021
@deepak1556 deepak1556 modified the milestones: July 2021, August 2021 Jul 26, 2021
@deepak1556 deepak1556 added the debt Code quality issues label Aug 23, 2021
@deepak1556 deepak1556 modified the milestones: August 2021, On Deck Aug 23, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debt Code quality issues engineering VS Code - Build / issue tracking / etc. freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues integration-test-failure upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

3 participants