Skip to content

Don't destroy _fileTransfer on shutdown#15792

Merged
xokdvium merged 1 commit intomasterfrom
filetransfer-shutdown
May 6, 2026
Merged

Don't destroy _fileTransfer on shutdown#15792
xokdvium merged 1 commit intomasterfrom
filetransfer-shutdown

Conversation

@edolstra
Copy link
Copy Markdown
Member

@edolstra edolstra commented May 4, 2026

Motivation

This is responsible for a lot of crash reports in Sentry (presumably due to destructor ordering issues). Since there is no cleanup done by this class that we care about, just leak it.

We can probably get rid of all the isQuitting() stuff, but this PR doesn't do that.

Context

Taken from DeterminateSystems#444.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This is responsible for a lot of crash reports in Sentry (presumably
due to destructor ordering issues). Since there is no cleanup done by
this class that we care about, just leak it.
@edolstra edolstra requested a review from Ericson2314 as a code owner May 4, 2026 17:44
@xokdvium
Copy link
Copy Markdown
Contributor

xokdvium commented May 4, 2026

Hm I feel like I should put up that match that disables all global destructors, otherwise we're going to play a game of whack-a-mole forever. I'll link it to this PR

@xokdvium
Copy link
Copy Markdown
Contributor

xokdvium commented May 6, 2026

Turns out we have global Store objects in getDefaultSubstituters, so we can't easily disable all the destructors for now, so it's easier to merge this for now.

Comment on lines +1186 to 1196
static auto * const _fileTransfer = new Sync<std::shared_ptr<curlFileTransfer>>;

ref<FileTransfer> getFileTransfer()
{
static ref<curlFileTransfer> fileTransfer = makeCurlFileTransfer();
auto fileTransfer(_fileTransfer->lock());

if (fileTransfer->state_.lock()->isQuitting())
fileTransfer = makeCurlFileTransfer();
if (!*fileTransfer || (*fileTransfer)->state_.lock()->isQuitting())
*fileTransfer = makeCurlFileTransfer().get_ptr();

return fileTransfer;
return ref<FileTransfer>(*fileTransfer);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Strictly speaking, we don't need the global but @edolstra tells me that it's used in detnix to hackily replace it after a fork in the child process, so it seems fine for now.

@xokdvium xokdvium added this pull request to the merge queue May 6, 2026
Merged via the queue into master with commit 5a72561 May 6, 2026
20 checks passed
@xokdvium xokdvium deleted the filetransfer-shutdown branch May 6, 2026 22:19
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.

2 participants