fix: segfault in SerialChooserController #25969
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This fixes #25781. The segfault was caused by the fact that the ScopedObserver on the SerialChooserController was trying to call RemovePortObserver on a SerialChooserContext that had already been destroyed.
Since this segfault was happening sporadically, I modified testing to run through the serial tests 100 times until it errored out.
Here's a test run of it segfaulting before the fix was applied:
https://app.circleci.com/pipelines/github/electron/electron/30787/workflows/9b8b67bb-e324-47b4-a9f4-c1a29dec83b9/jobs/678333
And here is a test run after the fix where it successfully ran serial port tests 100 times without segfault:
https://app.circleci.com/pipelines/github/electron/electron/31155/workflows/1fae9ecb-008e-4e2d-8ad9-cade5c72ac2a
Checklist
npm test
passesRelease Notes
Notes: Fixed crash while exiting Electron after using the Web Serial API.