Skip to content

fix: re-entrancy issues in webContents.loadURL() #48004

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codebytere
Copy link
Member

@codebytere codebytere commented Aug 8, 2025

Description of Change

Closes #40809

This fixes a crash possible when calling webContents.loadURL() from a failed call's catch handler. Essentially, a re-entrant navigation triggered from the did-start-navigation event causes the in-flight NavigationRequest to be destroyed before Chromium marks it safe, tripping the is_safe_to_delete_ DCHECK here.

Fix this by monitoring potential re-entrancy sites and failing if we try to call loadURL again at a dangerous time.

Checklist

Release Notes

Notes: Fixed a crash possible when calling webContents.loadURL() from a failed webContents.loadURL() call's catch handler.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Aug 8, 2025
@codebytere codebytere requested a review from deepak1556 August 8, 2025 10:52
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 8, 2025
@codebytere codebytere marked this pull request as ready for review August 8, 2025 10:53
@codebytere codebytere requested a review from jkleinsc August 8, 2025 10:53
Copy link
Member

@dsanders11 dsanders11 left a comment

Choose a reason for hiding this comment

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

Is this an edge case we could craft a test case for?

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 on the implementation

@codebytere
Copy link
Member Author

@dsanders11 added two more cases I think should cover it!

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Aug 9, 2025
@codebytere codebytere requested a review from dsanders11 August 10, 2025 19:50
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 target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Electron app will crash when loadURL or loadFile is called again
3 participants