microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.62k stars 28.67k forks source link

electron 30: crash in @parcel/watcher native module #214131

Closed brjsp closed 3 months ago

brjsp commented 3 months ago

This blocks electron 30 upgrade (did not ever observe it with electron 29)

Intermittent crashes after about a minute of use with the following stack trace:

#0  0x000055f132aa5cf0 in ?? ()
#1  0x000055f117b04d92 in v8impl::Reference::~Reference (this=<optimized out>, this=<optimized out>) at ../../third_party/electron_node/src/js_native_api_v8.cc:743
#2  napi_delete_reference (ref=0x7fd9ac008bb0, env=0x55f1329bad00) at ../../third_party/electron_node/src/js_native_api_v8.cc:2666
#3  napi_delete_reference (env=0x55f1329bad00, ref=0x7fd9ac008bb0) at ../../third_party/electron_node/src/js_native_api_v8.cc:2660
#4  0x00007fda7434a8ea in Napi::Reference<Napi::Function>::~Reference (this=<optimized out>, this=<optimized out>) at ../node_modules/node-addon-api/napi-inl.h:2503
#5  Napi::FunctionReference::~FunctionReference (this=<optimized out>, this=<optimized out>) at ../node_modules/node-addon-api/napi.h:1283
#6  std::__new_allocator<std::_Rb_tree_node<Napi::FunctionReference> >::destroy<Napi::FunctionReference> (__p=0x7fd9a032d550, this=<optimized out>) at /usr/include/c++/13/bits/new_allocator.h:198
#7  std::allocator_traits<std::allocator<std::_Rb_tree_node<Napi::FunctionReference> > >::destroy<Napi::FunctionReference> (__p=0x7fd9a032d550, __a=...) at /usr/include/c++/13/bits/alloc_traits.h:558
#8  std::_Rb_tree<Napi::FunctionReference, Napi::FunctionReference, std::_Identity<Napi::FunctionReference>, std::less<Napi::FunctionReference>, std::allocator<Napi::FunctionReference> >::_M_destroy_node (__p=0x7fd9a032d530, 
    this=<optimized out>) at /usr/include/c++/13/bits/stl_tree.h:625
#9  std::_Rb_tree<Napi::FunctionReference, Napi::FunctionReference, std::_Identity<Napi::FunctionReference>, std::less<Napi::FunctionReference>, std::allocator<Napi::FunctionReference> >::_M_drop_node (this=<optimized out>, 
    __p=0x7fd9a032d530) at /usr/include/c++/13/bits/stl_tree.h:633
#10 std::_Rb_tree<Napi::FunctionReference, Napi::FunctionReference, std::_Identity<Napi::FunctionReference>, std::less<Napi::FunctionReference>, std::allocator<Napi::FunctionReference> >::_M_erase(std::_Rb_tree_node<Napi::FunctionReference>*) [clone .isra.0] (__x=0x7fd9a032d530, this=<optimized out>) at /usr/include/c++/13/bits/stl_tree.h:1938
#11 0x00007fda743353c4 in std::_Rb_tree<Napi::FunctionReference, Napi::FunctionReference, std::_Identity<Napi::FunctionReference>, std::less<Napi::FunctionReference>, std::allocator<Napi::FunctionReference> >::~_Rb_tree (
    this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/stl_tree.h:736
#12 std::set<Napi::FunctionReference, std::less<Napi::FunctionReference>, std::allocator<Napi::FunctionReference> >::~set (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/stl_set.h:283
#13 Watcher::~Watcher (this=<optimized out>, this=<optimized out>) at ../src/Watcher.cc:55
#14 std::_Destroy<Watcher> (__pointer=0x55f1329bb6d0) at /usr/include/c++/13/bits/stl_construct.h:151
#15 std::allocator_traits<std::allocator<void> >::destroy<Watcher> (__p=0x55f1329bb6d0) at /usr/include/c++/13/bits/alloc_traits.h:675
#16 std::_Sp_counted_ptr_inplace<Watcher, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x55f1329bb6c0) at /usr/include/c++/13/bits/shared_ptr_base.h:613
#17 0x00007fda7433f94a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x55f1329bb6c0) at /usr/include/c++/13/bits/shared_ptr_base.h:346
#18 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x55f1329bb6c0) at /usr/include/c++/13/bits/shared_ptr_base.h:317
#19 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/shared_ptr_base.h:1071
#20 std::__shared_ptr<Watcher, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/shared_ptr_base.h:1524
#21 std::shared_ptr<Watcher>::~shared_ptr (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/shared_ptr.h:175
#22 std::__new_allocator<std::__detail::_Hash_node<std::shared_ptr<Watcher>, true> >::destroy<std::shared_ptr<Watcher> > (__p=0x55f132b46928, this=0x7fda7435f460 <_ZL14sharedWatchers.lto_priv.0>)
    at /usr/include/c++/13/bits/new_allocator.h:198
#23 std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::shared_ptr<Watcher>, true> > >::destroy<std::shared_ptr<Watcher> > (__p=0x55f132b46928, __a=...) at /usr/include/c++/13/bits/alloc_traits.h:558
#24 std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::shared_ptr<Watcher>, true> > >::_M_deallocate_node (this=0x7fda7435f460 <_ZL14sharedWatchers.lto_priv.0>, __n=0x55f132b46920)
    at /usr/include/c++/13/bits/hashtable_policy.h:2011
#25 std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::shared_ptr<Watcher>, true> > >::_M_deallocate_nodes (__n=0x0, this=0x7fda7435f460 <_ZL14sharedWatchers.lto_priv.0>)
    at /usr/include/c++/13/bits/hashtable_policy.h:2033
#26 std::_Hashtable<std::shared_ptr<Watcher>, std::shared_ptr<Watcher>, std::allocator<std::shared_ptr<Watcher> >, std::__detail::_Identity, WatcherCompare, WatcherHash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::clear (this=0x7fda7435f460 <_ZL14sharedWatchers.lto_priv.0>) at /usr/include/c++/13/bits/hashtable.h:2524
#27 std::_Hashtable<std::shared_ptr<Watcher>, std::shared_ptr<Watcher>, std::allocator<std::shared_ptr<Watcher> >, std::__detail::_Identity, WatcherCompare, WatcherHash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/hashtable.h:1608
#28 std::unordered_set<std::shared_ptr<Watcher>, WatcherHash, WatcherCompare, std::allocator<std::shared_ptr<Watcher> > >::~unordered_set (this=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/unordered_set.h:104
#29 0x00007fda7c2439e6 in __run_exit_handlers (status=0, listp=0x7fda7c3ef680 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
#30 0x00007fda7c243b30 in __GI_exit (status=<optimized out>) at exit.c:138
#31 0x00007fda7c22a1f7 in __libc_start_call_main (main=main@entry=0x55f111b13270 <main(int, char**)>, argc=argc@entry=21, argv=argv@entry=0x7ffe69b030e8) at ../sysdeps/nptl/libc_start_call_main.h:74
#32 0x00007fda7c22a2b9 in __libc_start_main_impl (main=0x55f111b13270 <main(int, char**)>, argc=21, argv=0x7ffe69b030e8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe69b030d8)
    at ../csu/libc-start.c:360
#33 0x000055f111b3e875 in _start () at ../sysdeps/x86_64/start.S:115

I've tried backporting https://github.com/parcel-bundler/watcher/commit/9b7c657df8ad1c0d020541eae0dd38b921c94fb8 and the crashes still happen (just with set destructor replaced by vector destructor above)

bpasero commented 3 months ago

Thanks for reporting, leaving to @deepak1556 to chime in.

bpasero commented 3 months ago

@brjsp do you reproduce this from our exploration builds that now use Electron 30?

VS Code Build: fc357074a7bba115fe44683d3f6050c63e591683

cli-alpine-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_alpine_arm64_cli.tar.gz
cli-alpine-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_alpine_x64_cli.tar.gz
cli-darwin-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_darwin_arm64_cli.zip
cli-darwin-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_darwin_x64_cli.zip
cli-linux-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_linux_arm64_cli.tar.gz
cli-linux-armhf: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_linux_armhf_cli.tar.gz
cli-linux-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_linux_x64_cli.tar.gz
cli-win32-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_win32_arm64_cli.zip
cli-win32-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/vscode_cli_win32_x64_cli.zip
darwin: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCode-darwin.zip
darwin-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCode-darwin-arm64.zip
darwin-universal: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCode-darwin-universal.zip
linux-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-arm64-1718269703.tar.gz
linux-armhf: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-armhf-1718269699.tar.gz
linux-deb-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration_1.91.0-1718269758_arm64.deb
linux-deb-armhf: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration_1.91.0-1718269750_armhf.deb
linux-deb-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration_1.91.0-1718271297_amd64.deb
linux-rpm-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-1.91.0-1718269844.el8.aarch64.rpm
linux-rpm-armhf: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-1.91.0-1718269826.el8.armv7hl.rpm
linux-rpm-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-1.91.0-1718271380.el8.x86_64.rpm
linux-snap-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-x64-1718272894.snap
linux-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/code-exploration-x64-1718269774.tar.gz
win32-arm64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCodeSetup-arm64-1.91.0-exploration.exe
win32-arm64-archive: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCode-win32-arm64-1.91.0-exploration.zip
win32-arm64-user: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCodeUserSetup-arm64-1.91.0-exploration.exe
win32-x64: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCodeSetup-x64-1.91.0-exploration.exe
win32-x64-archive: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCode-win32-x64-1.91.0-exploration.zip
win32-x64-user: https://vscode.download.prss.microsoft.com/dbazure/download/exploration/fc357074a7bba115fe44683d3f6050c63e591683/VSCodeUserSetup-x64-1.91.0-exploration.exe
brjsp commented 3 months ago

@bpasero I tried the linux-x64 build. It does not use Electron 30, in contradiction of what you said.

Version: 1.90.0-exploration
Commit: 26c4a07b47a2bd34480a5e4cba2c2384c590b039
Date: 2024-05-11T18:13:27.153Z
Electron: 29.3.1
ElectronBuildId: 9464424
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 6.9.3-1-default
bpasero commented 3 months ago

The commit needs to be fc357074a7bba115fe44683d3f6050c63e591683

brjsp commented 3 months ago

I was unable to get that build to recognize my data directory (because it's named “code-exploration” not “code”), so i have replaced the electron binaries and the native modules in my OSS install with the ones from code-exploration-x64-1718269774.tar.gz. No crashes so far.

brjsp commented 3 months ago

It also does not crash with the electron from your test build and our vscode binaries. This suggests it's an electron problem, not a @parcel/watcher problem.