8000 fix: only delete render_frame_host_ after OnDialogDone completes by VerteDinde · Pull Request #30916 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: only delete render_frame_host_ after OnDialogDone completes #30916

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

Merged
merged 1 commit into from
Sep 13, 2021

Conversation

VerteDinde
Copy link
Member
@VerteDinde VerteDinde commented Sep 10, 2021

Description of Change

Fixes #30858

There seems to be a race condition with two functions, OnFilesSelected and OnOpenDialogDone, when opening or attaching a file from the file dialog. On Windows and Linux, the execution goes something like this:

  1. Open dialog is triggered, user selects a file and clicks "Ok"
  2. OnFilesSelected runs. render_frame_host_ is set to nullptr and this is deleted
  3. OnOpenDialogDone runs. render_frame_host_ still exists when the function begins, and the nullptr checks don't trigger. However, the render_frame_host_ and this are then deleted in OnFilesSelected. When we then try to access render_frame_host_->GetProcess() at the end of the function, the program hard crashes.

It seems as though the render_frame_host_ deletion in OnFilesSelected was being done primarily for a different function, OnSaveDialogDone. This PR removes the nullptr reassignment from OnFilesSelected and instead calls RunFileChooserEnd in both [-]DialogDone functions, to make this behavior more predictable and dispose of the render_frame_host_ and web_contents_ properly.

NB: This file has been refactored and more thoroughly improved in @codebytere's PR here: #30663 This smaller fix will address the immediate crash behavior and is meant to be backported into 15-x-y, so we don't need to backport the refactor PR if needed.

Checklist

Release Notes

Notes: Fixed a crash when selecting files in a native file dialog on Windows and Linux.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Sep 10, 2021
@VerteDinde VerteDinde added semver/patch backwards-compatible bug fixes target/15-x-y labels Sep 10, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Sep 11, 2021
@VerteDinde VerteDinde merged commit b6a12a5 into main Sep 13, 2021
@VerteDinde VerteDinde deleted the file-open-crash-30858 branch September 13, 2021 13:25
@release-clerk
Copy link
release-clerk bot commented Sep 13, 2021

Release Notes Persisted

Fixes a crash when selecting files in a native file dialog on Windows and Linux.

@trop
Copy link
Contributor
trop bot commented Sep 13, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Crash on attaching the file using generic input type="file" form control
2 participants
0