Skip to content

fix: shutdown crash when unregistering power notification on windows - #50878

Merged
deepak1556 merged 4 commits into
mainfrom
robo/fix_pm_shutdown_crash
Apr 10, 2026
Merged

deepak1556 merged 4 commits into
mainfrom
robo/fix_pm_shutdown_crash

Conversation

@deepak1556

Copy link
Copy Markdown
Member

Description of Change

Extracted from #50465
Followup to #50045

Refs https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unregistersuspendresumenotification
the handle to unregister should be the return value of registeration api not the window handle.

Release Notes

Notes: Fixed shutdown crash on windows when power monitor notifications were subscribed.

@deepak1556 deepak1556 added semver/patch backwards-compatible bug fixes target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Apr 10, 2026
@deepak1556
deepak1556 requested a review from codebytere April 10, 2026 09:49
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Apr 10, 2026

@codebytere codebytere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm with a q or two!

@deepak1556
deepak1556 merged commit 05f1cb5 into main Apr 10, 2026
152 of 157 checks passed
@deepak1556
deepak1556 deleted the robo/fix_pm_shutdown_crash branch April 10, 2026 15:47
@release-clerk

release-clerk Bot commented Apr 10, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed shutdown crash on windows when power monitor notifications were subscribed.

@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot removed the target/39-x-y PR should also be added to the "39-x-y" branch. label Apr 10, 2026
@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "41-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/40-x-y needs-manual-bp/41-x-y and removed target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. labels Apr 10, 2026
@trop

trop Bot commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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

@trop trop Bot added in-flight/42-x-y merged/42-x-y PR was merged to the "42-x-y" branch. and removed target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/42-x-y labels Apr 10, 2026
@trop

trop Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@VerteDinde has manually backported this PR to "41-x-y", please check out #52999

MarshallOfSound pushed a commit that referenced this pull request Aug 19, 2026
…52999)

fix: shutdown crash when unregistering power notification on windows (#50878)

41-x-y note: PowerMonitor is not cppgc-managed on this branch, so only the RegisterSuspendResumeNotification handle fix is carried; the SelfKeepAlive removal does not apply.

(cherry picked from commit 05f1cb5)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
@trop trop Bot added merged/41-x-y PR was merged to the "41-x-y" branch. and removed in-flight/41-x-y labels Aug 19, 2026
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores

#47162 removed the WM_POWERBROADCAST handling from powerMonitor's message
window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (#54352)

* fix: stop registering powerMonitor for Windows suspend notifications it ignores

#47162 removed the WM_POWERBROADCAST handling from powerMonitor's message
window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.

* fix: complete ui::SessionChangeObserver where PowerMonitor is destroyed and emit directly

~PowerMonitor() is defined in electron_api_power_monitor.cc, which only saw
the forward declaration, so the unique_ptr member did not compile on
Windows. The session change callback already runs on the UI thread, so emit
there instead of posting an Unretained task that nothing can cancel.
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (#54384)

* fix: stop registering powerMonitor for Windows suspend notifications it ignores

#47162 removed the WM_POWERBROADCAST handling from powerMonitor's message
window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.

Co-authored-by: Sam Attard <[email protected]>

* fix: complete ui::SessionChangeObserver where PowerMonitor is destroyed and emit directly

~PowerMonitor() is defined in electron_api_power_monitor.cc, which only saw
the forward declaration, so the unique_ptr member did not compile on
Windows. The session change callback already runs on the UI thread, so emit
there instead of posting an Unretained task that nothing can cancel.

Co-authored-by: Sam Attard <[email protected]>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Sam Attard <[email protected]>
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…it ignores (44-x-y) (#54408)

fix: stop registering powerMonitor for Windows suspend notifications it ignores (#54352)

* fix: stop registering powerMonitor for Windows suspend notifications it ignores

window (suspend/resume come from base::PowerMonitor), but left the
RegisterSuspendResumeNotification() call behind. That registration no
longer fed anything and its unregistration is the ARM64 shutdown crash
that #50045, #50878 and #51198 have been chasing.

Drop the private message window entirely and take session lock/unlock
from ui::SessionChangeObserver, which registers WTS notifications on the
UI thread's singleton window and already filters to the current session.

* fix: complete ui::SessionChangeObserver where PowerMonitor is destroyed and emit directly

~PowerMonitor() is defined in electron_api_power_monitor.cc, which only saw
the forward declaration, so the unique_ptr member did not compile on
Windows. The session change callback already runs on the UI thread, so emit
there instead of posting an Unretained task that nothing can cancel.

(cherry picked from commit 98704f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. new-pr 🌱 PR opened recently semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants