Skip to content

fix(libstore/filetransfer): prevent double callback invocation on interrupt during retry#14418

Merged
edolstra merged 1 commit intoNixOS:masterfrom
lovesegfault:fix-curl-interrupt
Oct 30, 2025
Merged

fix(libstore/filetransfer): prevent double callback invocation on interrupt during retry#14418
edolstra merged 1 commit intoNixOS:masterfrom
lovesegfault:fix-curl-interrupt

Conversation

@lovesegfault
Copy link
Member

Motivation

Fix a race condition where interrupting a download (via Ctrl-C) during a
retry attempt could cause a crash. When enqueueItem() throws because the
download thread is shutting down, the exception would propagate without
setting done=true, causing the TransferItem destructor to invoke the
callback a second time.

This triggered an assertion failure in Callback::rethrow() with:
Assertion '!prev' failed and the error message cannot enqueue download request because the download thread is shutting down.

The fix catches the exception from enqueueItem() and calls fail() to
properly complete the transfer, ensuring the callback is invoked exactly
once.

Context


Add 👍 to pull requests you find important.

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

…errupt during retry

Fix a race condition where interrupting a download (via Ctrl-C) during a
retry attempt could cause a crash. When `enqueueItem()` throws because the
download thread is shutting down, the exception would propagate without
setting `done=true`, causing the `TransferItem` destructor to invoke the
callback a second time.

This triggered an assertion failure in `Callback::rethrow()` with:
`Assertion '!prev' failed` and the error message `cannot enqueue download
request because the download thread is shutting down`.

The fix catches the exception from `enqueueItem()` and calls `fail()` to
properly complete the transfer, ensuring the callback is invoked exactly
once.
@edolstra edolstra added this pull request to the merge queue Oct 30, 2025
Merged via the queue into NixOS:master with commit 2cc5320 Oct 30, 2025
17 checks passed
@lovesegfault lovesegfault deleted the fix-curl-interrupt branch October 31, 2025 22:25
@edolstra edolstra mentioned this pull request Dec 9, 2025
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.

3 participants