Skip to content

Fix mtx_do_lock on exit or reload context#170

Merged
ianhattendorf merged 2 commits intoAxosoft:masterfrom
julianmesa-gitkraken:fix-mtx_do_lock
Dec 2, 2022
Merged

Fix mtx_do_lock on exit or reload context#170
ianhattendorf merged 2 commits intoAxosoft:masterfrom
julianmesa-gitkraken:fix-mtx_do_lock

Conversation

@julianmesa-gitkraken
Copy link
Copy Markdown
Contributor

@julianmesa-gitkraken julianmesa-gitkraken commented Nov 18, 2022

We made an effort to try using AddCleanupHook to stop the watcher on all NSFW instances when exiting from a worker or electron context, but in the end we couldn’t make it work correctly, so we had to stop using them.
The reason is that using CleanupHooks introduces a problem: if you create and free a NSFW object when you close o reload a context or worker the CleanupHook will be triggered on an already freed object, so you will get a crash. We have tried to remove the CleanupHook before that, but you will get a crash if you try to remove it in the destructor. You cannot create or remove a CleanupHook anywhere you want, you can only do it when you have access to Napi::env directly in the call, and you cannot store it to use it later in the destructor.

@julianmesa-gitkraken
Copy link
Copy Markdown
Contributor Author

To use cleanuphooks again we need this PR merged.

@ianhattendorf ianhattendorf merged commit 2da89e1 into Axosoft:master Dec 2, 2022
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.

2 participants