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: avoid crash after upgrade on Linux #41046

Merged
merged 1 commit into from May 7, 2024

Conversation

cptpcrd
Copy link
Contributor

@cptpcrd cptpcrd commented Jan 18, 2024

Description of Change

Don't perform the "known executable" check on Linux if /proc/self/exe is going to be executed.

If the executable has been unlinked -- e.g. by the system package manager to perform an upgrade of an Electron-based app -- then executing /proc/self/exe will still work to launch copies of the same program since it is a "magic link" (see symlink(7)). However, this check breaks: readlink("/proc/self/exe") returns a fake path like /usr/lib/electron28/electron (deleted) which does not actually exist, so base::MakeAbsoluteFilePath fails to resolve the path and instead returns an empty string. This in turn causes the CHECK_EQ a few lines down to fail, and Electron crashes.

I think this is responsible for the crashes mentioned in #27804 and #33315.

Reproduction instructions for the crash (on Linux)
  1. Download a copy of Electron to a temporary directory, e.g: cd $(mktemp -d); wget https://github.com/electron/electron/releases/download/v28.1.4/electron-v28.1.4-linux-x64.zip; unzip electron-v28.1.4-linux-x64.zip
  2. Run ./electron -i.
  3. In a different terminal, cd to the same temporary directory and run rm ./electron.
  4. In the original terminal, run b = new BrowserWindow(); b.toggleDevTools().
  5. Electron crashes.

Checklist

Release Notes

Notes: Fixed crash after upgrade on Linux.

Copy link

welcome bot commented Jan 18, 2024

💖 Thanks for opening this pull request! 💖

We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix.

Examples of commit messages with semantic prefixes:

  • fix: don't overwrite prevent_default if default wasn't prevented
  • feat: add app.isPackaged() method
  • docs: app.isDefaultProtocolClient is now available on Linux

Things that will help get your PR across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.

We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 18, 2024
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 25, 2024
@codebytere
Copy link
Member

Small lint issue:

$ node ./script/lint.js && npm run lint:docs
shell/browser/electron_browser_client.cc:463:  (cpplint) If/else bodies with multiple statements require braces  [readability/braces] [4]
Total errors found: 1

@cptpcrd
Copy link
Contributor Author

cptpcrd commented Feb 29, 2024

@codebytere are there any other changes you'd like to see here?

@zcbenz zcbenz added semver/patch backwards-compatible bug fixes target/28-x-y PR should also be added to the "28-x-y" branch. target/29-x-y PR should also be added to the "29-x-y" branch. target/30-x-y PR should also be added to the "30-x-y" branch. labels Mar 4, 2024
@zcbenz
Copy link
Member

zcbenz commented Mar 4, 2024

Can you rebase on latest main? Which should be able to fix the Windows CI failure.

@cptpcrd
Copy link
Contributor Author

cptpcrd commented Mar 4, 2024

It's a bit unclear to me why the Linux/mac builds failed.

@cptpcrd cptpcrd force-pushed the linux-upgrade-crash branch 2 times, most recently from f91a77a to 42d742d Compare March 29, 2024 12:15
@cptpcrd cptpcrd requested a review from codebytere April 13, 2024 00:41
@github-actions github-actions bot added the target/31-x-y PR should also be added to the "31-x-y" branch. label Apr 17, 2024
@cptpcrd cptpcrd requested a review from zcbenz May 1, 2024 13:49
@codebytere codebytere merged commit d5c8f2d into electron:main May 7, 2024
15 of 17 checks passed
Copy link

release-clerk bot commented May 7, 2024

Release Notes Persisted

Fixed crash after upgrade on Linux.

Copy link

welcome bot commented May 7, 2024

Congrats on merging your first pull request! 🎉🎉🎉

@trop
Copy link
Contributor

trop bot commented May 7, 2024

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

@trop trop bot added in-flight/31-x-y and removed target/31-x-y PR should also be added to the "31-x-y" branch. labels May 7, 2024
@trop
Copy link
Contributor

trop bot commented May 7, 2024

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

@trop
Copy link
Contributor

trop bot commented May 7, 2024

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

@trop
Copy link
Contributor

trop bot commented May 7, 2024

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

@trop trop bot added in-flight/28-x-y in-flight/30-x-y in-flight/29-x-y and removed target/28-x-y PR should also be added to the "28-x-y" branch. target/30-x-y PR should also be added to the "30-x-y" branch. target/29-x-y PR should also be added to the "29-x-y" branch. in-flight/28-x-y labels May 7, 2024
@cptpcrd cptpcrd deleted the linux-upgrade-crash branch May 7, 2024 14:17
@trop trop bot added merged/29-x-y PR was merged to the "29-x-y" branch. merged/30-x-y PR was merged to the "30-x-y" branch. merged/31-x-y PR was merged to the "31-x-y" branch. and removed in-flight/29-x-y in-flight/30-x-y in-flight/31-x-y labels May 8, 2024
Mrnikifabio pushed a commit to Mrnikifabio/electron that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/29-x-y PR was merged to the "29-x-y" branch. merged/30-x-y PR was merged to the "30-x-y" branch. merged/31-x-y PR was merged to the "31-x-y" branch. semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants