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

Crash in V8 when using Node FFI modules #122565

Closed
isc-AndrewCheshire opened this issue Apr 28, 2021 · 4 comments
Closed

Crash in V8 when using Node FFI modules #122565

isc-AndrewCheshire opened this issue Apr 28, 2021 · 4 comments
Assignees
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@isc-AndrewCheshire
Copy link

Issue Type: Bug

The crash occurs when the InterSystems Language Server extension is activated.

The extension calls out from JavaScript to an InterSystems shared library (packaged with the extension) and then uses the following Node FFI modules to turn the returned result into JavaScript objects:

  • ffi-napi 4.0.3
  • ref-array-napi 1.2.2
  • ref-napi 3.0.2
  • ref-struct-napi 1.1.1

Although we have been using older versions of these modules the crash also occurs with these latest versions of them.

This works fine with VSCode Stable (and has done for months) but crashes on Insiders. It also works fine with stand-alone Node.

The crash actually occurs when the JavaScript code either uses toArray or attempts to access a part of the returned object using subscripting (i.e. [..]). The last JS code executed before calling native code is in ref-napi: ref.js calls _reinterpret to "reinterpret" the buffer by - as I understand it - creating a larger buffer at the same address.

I have attached a zip of the .dmp file created by VSCode Insiders.

ER: The Language Server extension starts up and functions normally

AR: The Language Server crashes on activation and (after a retry) disconnects from the client.

VS Code version: Code - Insiders 1.56.0-insider (13f1aff, 2021-04-28T04:50:45.511Z)
OS version: Darwin x64 18.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (8 x 4200)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 1, 2, 2
Memory (System) 32.00GB (6.63GB free)
Process Argv --crash-reporter-directory /Users/andyc/crash
Screen Reader no
VM 0%
Extensions (3)
Extension Author (truncated) Version
servermanager int 2.0.3
vscode-objectscript int 1.0.10
language-server int 1.1.4
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
pythonvspyt602:30291494
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry914:30244316
pythonvspyt639:30291487
pythontb:30258533
vspre833:30267464
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscus158:30286553
vscgsv2ct:30286873
vscorehov:30294388
3f5j7703:30294757

a47c8fa5-5629-44e8-9b59-52c9caa07aae.dmp.zip

@isc-AndrewCheshire
Copy link
Author

I'm not sure whether this is included in the .dmp file so here's the error report and stack trace:

#
# Fatal error in , line 0
# ignored
#
#
#
#FailureMessage Object: 0x7ffee10b4a50
 1: 0x111306b72 node::MultiIsolatePlatform::CancelPendingDelayedTasks(v8::Isolate*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x11454a8b1 v8::internal::compiler::ZoneStats::GetCurrentAllocatedBytes() const [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x10f64e713 v8::internal::BackingStore::Reallocate(v8::internal::Isolate*, unsigned long) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x10f495044 v8::ArrayBuffer::GetBackingStore() [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 5: 0x1112607a9 napi_get_typedarray_info [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 6: 0x11710bffd Napi::TypedArrayOf<unsigned char>::TypedArrayOf(napi_env__*, napi_value__*) [/Users/andyc/git/language-server/server/node_modules/ref-array-napi/node_modules/ref-napi/build/Release/binding.node]
 7: 0x11710a0ae (anonymous namespace)::WrapPointer(Napi::Env, char*, unsigned long) [/Users/andyc/git/language-server/server/node_modules/ref-array-napi/node_modules/ref-napi/build/Release/binding.node]
 8: 0x11710b698 (anonymous namespace)::ReinterpretBuffer(Napi::CallbackInfo const&) [/Users/andyc/git/language-server/server/node_modules/ref-array-napi/node_modules/ref-napi/build/Release/binding.node]
 9: 0x1170c7ef3 napi_value__* Napi::details::WrapCallback<Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()>(Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*)::'lambda'()) [/Users/andyc/git/language-server/server/node_modules/ref-napi/build/Release/binding.node]
10: 0x1170c7ea9 Napi::details::CallbackData<Napi::Value (*)(Napi::CallbackInfo const&), Napi::Value>::Wrapper(napi_env__*, napi_callback_info__*) [/Users/andyc/git/language-server/server/node_modules/ref-napi/build/Release/binding.node]
11: 0x111262013 napi_is_detached_arraybuffer [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
12: 0x10f4c54a0 v8::internal::ClassScope::ResolvePrivateNamesPartially() [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
13: 0x10f4c50f5 v8::internal::ClassScope::ResolvePrivateNamesPartially() [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
14: 0x10f4c4773 v8::internal::ClassScope::ResolvePrivateNamesPartially() [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
15: 0x10fb1b478 v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
16: 0x10fab52ef v8::internal::SetupIsolateDelegate::SetupHeap(v8::internal::Heap*) [/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]

@gjsjohnmurray
Copy link
Contributor

@deepak1556 is this your domain?

@isc-bsaviano
Copy link

Original issue: intersystems/language-server#152

@alexdima alexdima added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Apr 28, 2021
@deepak1556
Copy link
Collaborator

Thanks for the ping @gjsjohnmurray.

Insiders has updated to node v14 which disallows creating two ArrayBuffer instances pointing to the same memory nodejs/node#32463. ref-napi seems to have addressed this in node-ffi-napi/ref-napi@aede905 but there are still users reporting to hit this with 3.0.2 on node v14 node-ffi-napi/ref-napi#47. I would suggest to create a minimal repro and report it in the module to get the issue fixed, there is not much vscode can do here.

Also, I noticed that you are using ref-struct-napi and ref-array-napi, it is recommended to use ref-struct-di and ref-array-di node-ffi-napi/ref-napi@e36f35e

@deepak1556 deepak1556 added upstream Issue identified as 'upstream' component related (exists outside of VS Code) and removed freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues labels Apr 28, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

5 participants