Navigation Menu

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: Shutdown crash in DownloadItem callback #27419

Conversation

trop[bot]
Copy link
Contributor

@trop trop bot commented Jan 20, 2021

Backport of #27342

See that PR for details.

Notes: Fixed shutdown crash when quitting with in-progress downloads

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jan 20, 2021
@trop trop bot added 11-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Jan 20, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Jan 20, 2021
The call stack for one of our top crashes looks like this:

```
node::Abort (node_errors.cc:241)
node::Assert (node_errors.cc:256)
node::MakeCallback (callback.cc:226)
gin_helper::internal::CallMethodWithArgs (event_emitter_caller.cc:23)
gin_helper::EmitEvent<T> (event_emitter_caller.h:51)
gin_helper::EventEmitterMixin<T>::Emit<T> (event_emitter_mixin.h:81)
electron::api::DownloadItem::OnDownloadUpdated (electron_api_download_item.cc:115)
download::DownloadItemImpl::UpdateObservers (download_item_impl.cc:482)
content::DownloadManagerImpl::Shutdown (download_manager_impl.cc:508)
content::BrowserContext::~BrowserContext (browser_context.cc:476)
```

Full stack here: https://sentry.io/share/issue/9b030a0601b547188181b543c16ecda2/

During browser shutdown, the `DownloadManager` was being cleaned up
*after* the Node environment had already been destroyed. This caused the
`DownloadItem::OnDownloadUpdated` callback to crash when trying to emit
the JS `done` event.

To prevent this, we now manually shut down the `DownloadManager`
earlier. This is also mentioned in the comment on
`DownloadManager::Shutdown`:

```
// Shutdown the download manager. Content calls this when BrowserContext is
// being destructed. If the embedder needs this to be called earlier, it can
// call it. In that case, the delegate's Shutdown() method will only be called
// once.
```
@codebytere codebytere force-pushed the trop/11-x-y-bp-fix-shutdown-crash-in-downloaditem-callback-1611171071936 branch from 04ca18e to 78474ed Compare January 20, 2021 21:54
@zcbenz zcbenz merged commit aa4f355 into 11-x-y Jan 21, 2021
@release-clerk
Copy link

release-clerk bot commented Jan 21, 2021

Release Notes Persisted

Fixed shutdown crash when quitting with in-progress downloads

@zcbenz zcbenz deleted the trop/11-x-y-bp-fix-shutdown-crash-in-downloaditem-callback-1611171071936 branch January 21, 2021 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants