question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Using node-usb on the Electron main process by exiting a crash popup is displayed

See original GitHub issue

Electron Version

9 <13

What operating system are you using?

macOS

Operating System Version

macOS 11.5

What arch are you using?

x64

Last Known Working Electron version

8.5.5

Expected Behavior

After exit Electron, no crash is expected

Actual Behavior

When I close electron on macOS after having created a listener using node-usb and calling removeListener on ‘window-all-closed’, Electron throws an exception EXC_BAD_ACCESS (SIGSEGV)

`Crashed Thread: 0 CrBrowserMain Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: EXC_I386_GPFLT Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11 Termination Reason: Namespace SIGNAL, Code 0xb Terminating Process: exc handler [34544]

Thread 0 Crashed:: CrBrowserMain Dispatch queue: com.apple.main-thread 0 com.github.Electron.framework 0x000000010a6f02a0 napi_delete_reference + 48 1 usb_bindings.node 0x0000000113a8b6c0 0x113a88000 + 14016 2 libsystem_c.dylib 0x00007fff20400d25 __cxa_finalize_ranges + 316 3 libsystem_c.dylib 0x00007fff20401010 exit + 53 4 libdyld.dylib 0x00007fff204ecf44 start + 8 `

image image

Testcase Gist URL

https://github.com/danielmain/electron-crash-using-usb

Additional Information

I have created a stupid simple electron application that reproduce the problem.

Repo: https://github.com/danielmain/electron-crash-using-usb

  1. Clone it
  2. Run: yarn install && yarn start
  3. Close the application and after some seconds you will see the crash

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
thegeckocommented, Aug 13, 2021

Awesome work on reproducing this issue with a repo. Please bear with me checking the fix, I’m on vacation.

Has the change been tried on Linux/Windows systems?

I also notice there’s a warning when using this method:

https://github.com/nodejs/node-addon-api/blob/main/doc/reference.md#suppressdestruct

1reaction
danielmaincommented, Aug 10, 2021

If I disable the line node_usb.cc:175 there is no crash, but I am not able to communicate with the USB device

// hotplugThis.Reset(info.This().As<Napi::Object>(), 1);

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: Crash on `app.exit()` · Issue #29260 · electron ... - GitHub
Very simple program did not cause this issue. So I describe how I caused this issue with my application. Frequency is 100%. At...
Read more >
Bug #1944468 “Electron applications all crash upon launch”
The only thing these applications have in common is electron. I was hoping this would get ... GPU process exited unexpectedly: exit_code=159
Read more >
Electron app crashes when storing data to system (app exited ...
I am working on an electron app, and I'm using an the following class ... via `remote`, whereas the main process can get...
Read more >
nonolith - Bountysource
Hello I'm trying to use this node-usb library for my electron react application but when I run the code inside the electron container,...
Read more >
Breaking Changes - Electron.js
This document uses the following convention to categorize breaking changes: API Changed: An API was changed in such a way that code that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found