Skip to content

fix: only delete render_frame_host_ after OnDialogDone completes - #30916

Merged
VerteDinde merged 1 commit into
mainfrom
file-open-crash-30858
Sep 13, 2021
Merged

VerteDinde merged 1 commit into
mainfrom
file-open-crash-30858

Conversation

@VerteDinde

@VerteDinde VerteDinde commented Sep 10, 2021 •

Copy link
Copy Markdown
Member

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

release-clerk Bot commented Sep 13, 2021

Copy link
Copy Markdown

Release Notes Persisted

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

@trop

trop Bot commented Sep 13, 2021

Copy link
Copy Markdown
Contributor

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