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: Notification crash in destructor on app quit #21709

Merged
merged 1 commit into from Jan 9, 2020
Merged

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Jan 8, 2020

Description of Change

Closes #19842.
Closes #18701.

Previously, when you close the api notification, that notification forgets about the platform notification. As such, when it is destroyed it will not call set_delegate(nullptr). The notification can be reset here without the delegate having been reset, which creates the conditions necessary for this crash. This PR fixes that by ensuring that the delegate is always set to nullptr before the notification is reset.

cc @MarshallOfSound @nornagon

h/t to @charlag for great work investigating this!

Checklist

Release Notes

Notes: Fixed a crash that would occur when Notifications were closed in concert with app termination.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 8, 2020
@codebytere codebytere changed the title fix: Notification crash in before-quit fix: Notification crash ion app quit Jan 8, 2020
@codebytere codebytere changed the title fix: Notification crash ion app quit fix: Notification crash in destructor on app quit Jan 8, 2020
Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

Seems a bit fishy to me that setting the delegate to nullptr on an object that is then immediately destroyed would change behavior. Is the notification being used after having been freed..?

@codebytere
Copy link
Member Author

codebytere commented Jan 8, 2020

@nornagon see #19842 (comment) for more context :)

Copy link
Member

@nornagon nornagon left a comment

Choose a reason for hiding this comment

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

ah, I missed that notification_ here is a WeakPtr and not a unique_ptr.

@codebytere codebytere merged commit f5e202a into master Jan 9, 2020
@release-clerk
Copy link

release-clerk bot commented Jan 9, 2020

Release Notes Persisted

Fixed a crash that would occur when Notifications were closed in concert with app termination.

@trop
Copy link
Contributor

trop bot commented Jan 9, 2020

I have automatically backported this PR to "6-1-x", please check out #21718

@trop
Copy link
Contributor

trop bot commented Jan 9, 2020

I have automatically backported this PR to "7-1-x", please check out #21719

@trop
Copy link
Contributor

trop bot commented Jan 9, 2020

I have automatically backported this PR to "8-x-y", please check out #21720

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.

Crash on exit Notification close() causes app crash at exit
4 participants