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(extensions): define platform info to prevent renderer crash #25357

Merged
merged 4 commits into from Sep 15, 2020

Conversation

samuelmaddock
Copy link
Member

@samuelmaddock samuelmaddock commented Sep 7, 2020

Description of Change

Fully implements chrome.runtime.getPlatformInfo such that the calling renderer won't crash/hang.

The implementation is copied from chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc.

Ref #19447

cc @nornagon @sentialx

Checklist

Release Notes

Notes: Fixed chrome.runtime.getPlatformInfo crashing the background process upon being invoked.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Sep 7, 2020
@sentialx
Copy link
Contributor

sentialx commented Sep 8, 2020

LGTM

@nornagon
Copy link
Member

nornagon commented Sep 8, 2020

Looks like you're missing a dependency declaration in the BUILD.gn file:

ERROR at //electron/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.cc:10:11: Can't include this header from here.
#include "components/update_client/update_query_params.h"
          ^---------------------------------------------
The target:
  //electron:electron_lib
is including a file from the target:
  //components/update_client:update_client

While it's a little questionable for us to be making a dependency on something called "update client" (given we don't use any of the actual functionality of that component), we're already transitively dependent on it via //extensions/browser, so adding it as an explicit dependency seems OK.

@nornagon
Copy link
Member

nornagon commented Sep 8, 2020

Also, I'm surprised this crashed before. Can you provide some more info about the crash this fixes?

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 8, 2020
@samuelmaddock
Copy link
Member Author

Also, I'm surprised this crashed before. Can you provide some more info about the crash this fixes?

@nornagon what seems to happen is the API attempts to use PlatformInfo in a response, but doesn't handle it well when some of the fields aren't initialized. Specifically the call to runtime::GetPlatformInfo::Results::Create(info). Then runtime::ToString is called on uninitialized data in a PlatformInfo generated function.

The Runtime API Delegate relies on values from this component.
Copy link

@gittysachin gittysachin left a comment

Choose a reason for hiding this comment

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

So far, LGTM

@codebytere codebytere merged commit 45170fd into electron:master Sep 15, 2020
@release-clerk
Copy link

release-clerk bot commented Sep 15, 2020

Release Notes Persisted

Fixed chrome.runtime.getPlatformInfo crashing the background process upon being invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants