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

Fix Segfault on Electron Exit #501

Merged
merged 35 commits into from
Nov 10, 2023
Merged

Fix Segfault on Electron Exit #501

merged 35 commits into from
Nov 10, 2023

Conversation

xiazhvera
Copy link
Contributor

@xiazhvera xiazhvera commented Nov 7, 2023

Issue #, if available:

Description of changes:
As Electron would shutdown the node process on exit, and eventually causing "segfault" on threadsafe function operation. We now disable the node threadsafe functions on node process exit to prevent the segfault.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@xiazhvera xiazhvera changed the title Protect Threadsafe function on Electron Exit Fix Segfault on Electron Exit Nov 7, 2023
@xiazhvera xiazhvera marked this pull request as ready for review November 7, 2023 22:25
lib/native/binding.js Outdated Show resolved Hide resolved
Copy link
Contributor

@bretambrose bretambrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per convo, check to see if the rw lock could be put on the module data rather than a static global. We also want to run our full test suite in a CI environment where each test gets run as a standalone electron app, but that can wait for a separate task, since we've partitioned the callback cutoff away from standard node execution.

@xiazhvera
Copy link
Contributor Author

Though it is possible to put the rw lock on module data, I didn't find a good way to retrieve the module data when we do threadsafe function operations. One possible solution is to make the whole module data a global static, while I feel it was meaningless to do so...
I will setup a separate task for running test suite in Electron.

Base automatically changed from no_external_buffers to main November 9, 2023 22:45
@xiazhvera xiazhvera merged commit 64b096b into main Nov 10, 2023
@xiazhvera xiazhvera deleted the tsfn_protect branch November 10, 2023 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants