Skip to content

Conversation

@edolstra
Copy link
Member

Motivation

When this function is called as a coroutine (e.g. when it's called by copyStorePath()), the code after decompressor->finish() is never reached because the coroutine is destroyed when the caller reaches the end of the NAR. So put that code in a LambdaSink destructor.

Context

Noticed while doing DeterminateSystems#279.


Add 👍 to pull requests you find important.

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

When this function is called as a coroutine (e.g. when it's called by
`copyStorePath()`), the code after `decompressor->finish()` is never
reached because the coroutine is destroyed when the caller reaches the
end of the NAR. So put that code in a `LambdaSink` destructor.
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Nov 25, 2025
@Ericson2314 Ericson2314 requested a review from xokdvium November 25, 2025 17:56
Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I would like @xokdvium to give it a quick glance

stats.narRead++;
// stats.narReadCompressedBytes += nar->size(); // FIXME
stats.narReadBytes += narSize.length;
// Note: don't do anything here because it's never reached if we're called as a coroutine.
Copy link
Contributor

@xokdvium xokdvium Nov 25, 2025

Choose a reason for hiding this comment

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

But if this code doesn't run then how is the destructor (for LambdaSink) being run? Would be nice to add a unit test for the issue so it's more clear what's being fixed

Copy link
Member Author

Choose a reason for hiding this comment

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

Boost unwinds the coroutine stack by throwing an exception of type boost::context::detail::forced_unwind. So destructors of stack variables do get executed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

@edolstra edolstra added this pull request to the merge queue Nov 26, 2025
Merged via the queue into master with commit 2e262c6 Nov 26, 2025
20 checks passed
@edolstra edolstra deleted the binary-cache-nar-from-path branch November 26, 2025 10:39
@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

store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants