Skip to content
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

fix: printing optional access crash on Windows #38976

Merged
merged 1 commit into from Jul 10, 2023
Merged

Conversation

codebytere
Copy link
Member

Description of Change

Closes #38975
Closes #38944

Refs CL:4412367 and CL:4409898

Fixes an issue where printing on Windows could trigger a RAW: Bad optional access crash. This happened as a result of cloning job_settings and calling std::move on it in the same function call, which interestingly works just fine on macOS but doesn't on Windows.

Checklist

Release Notes

Notes: Fixes an issue where printing on Windows could trigger a crash.

@codebytere codebytere added semver/patch backwards-compatible bug fixes target/25-x-y PR should also be added to the "25-x-y" branch. target/26-x-y PR should also be added to the "26-x-y" branch. labels Jul 3, 2023
@codebytere codebytere requested a review from a team as a code owner July 3, 2023 15:02
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 3, 2023
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jul 4, 2023
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

I think I understand the crash now, the old code was basically doing this:

SetSettings(job_settings.Clone(), std::move(job_settings));

and the result would depend on the order of parameter evaluation: for environments that evaluate job_settings.Clone() first, things work expected; but for environments that evaluate std::move(job_settings) first, the cloned value would be null.

So this PR does correctly fix the crash, but there should be some comments added on why it works.

@jkleinsc jkleinsc merged commit 117a700 into main Jul 10, 2023
16 checks passed
@jkleinsc jkleinsc deleted the fix-printing-win branch July 10, 2023 13:26
@release-clerk
Copy link

release-clerk bot commented Jul 10, 2023

Release Notes Persisted

Fixes an issue where printing on Windows could trigger a crash.

@trop
Copy link
Contributor

trop bot commented Jul 10, 2023

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

@trop trop bot added needs-manual-bp/25-x-y and removed target/25-x-y PR should also be added to the "25-x-y" branch. labels Jul 10, 2023
@trop
Copy link
Contributor

trop bot commented Jul 10, 2023

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

@trop trop bot added in-flight/26-x-y merged/26-x-y PR was merged to the "26-x-y" branch. and removed target/26-x-y PR should also be added to the "26-x-y" branch. in-flight/26-x-y labels Jul 10, 2023
@trop
Copy link
Contributor

trop bot commented Jul 13, 2023

@codebytere has manually backported this PR to "25-x-y", please check out #39095

@trop trop bot added in-flight/25-x-y merged/25-x-y PR was merged to the "25-x-y" branch. and removed in-flight/25-x-y labels Jul 13, 2023
MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/25-x-y PR was merged to the "25-x-y" branch. merged/26-x-y PR was merged to the "26-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: error callback on print [Bug]: print() crashes on Windows, but works on macOS
3 participants