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: delay emitting screen events by a tick to avoid re-entrancy crash #19016

Merged
merged 1 commit into from Jun 28, 2019

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Jun 27, 2019

If user code created / destroyed windows inside a screen event handler it could cause re-entrancy on the WndProc handler for screen related events causing memory corruption. If we delay the events going to user we won't re-entry and everything will be fine.

Notes: Fixed crash when creating certain types of windows in the display-* events

@MarshallOfSound MarshallOfSound requested a review from a team as a code owner June 27, 2019 18:06
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jun 27, 2019
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.

Can we solve this by not running JS directly in the OnDisplay* callbacks, but instead posting a task to run the JS after the message has completed processing?

@MarshallOfSound
Copy link
Member Author

@nornagon I tried that locally but it didn't consistently fix it, this did. I also think we can't guarantee that our code is the only thing that could trigger a re-entry. We should ensure this method can handle re-entry no matter what causes it,

@MarshallOfSound MarshallOfSound changed the title fix: add a patch to the DisplayChangeNotifier to prevent a crash in display-added fix: delay emitting screen events by a tick to avoid re-entrancy crash Jun 27, 2019
shell/browser/api/atom_api_screen.cc Outdated Show resolved Hide resolved
shell/browser/api/atom_api_screen.cc Outdated Show resolved Hide resolved
shell/browser/api/atom_api_screen.cc Outdated Show resolved Hide resolved
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

LGTM, with some style comments

shell/browser/api/atom_api_screen.cc Outdated Show resolved Hide resolved
shell/browser/api/atom_api_screen.cc Outdated Show resolved Hide resolved
@MarshallOfSound MarshallOfSound merged commit 127d617 into master Jun 28, 2019
@release-clerk
Copy link

release-clerk bot commented Jun 28, 2019

Release Notes Persisted

Fixed crash when creating certain types of windows in the display-* events

@MarshallOfSound MarshallOfSound deleted the fix-display-added-crash branch June 28, 2019 02:01
@trop
Copy link
Contributor

trop bot commented Jun 28, 2019

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

@trop
Copy link
Contributor

trop bot commented Jun 28, 2019

I have automatically backported this PR to "5-0-x", please check out #19023

@trop
Copy link
Contributor

trop bot commented Jun 28, 2019

I have automatically backported this PR to "4-2-x", please check out #19024

@sofianguy sofianguy added this to Fixed in 6.0.0-beta.12 in 6.1.x Jul 10, 2019
@sofianguy sofianguy added this to Fixed in 5.0.7 in 5.0.x Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-pr 🌱 PR opened in the last 24 hours
Projects
No open projects
5.0.x
Fixed in 5.0.7
6.1.x
Fixed in 6.0.0-beta.12
Development

Successfully merging this pull request may close these issues.

None yet

3 participants