Skip to content

Use hardcoded psmdcp name to fix deterministic pack file-handle leak#7503

Merged
nkolev92 merged 3 commits into
devfrom
dev-nkolev92-14959
Jun 25, 2026
Merged

Use hardcoded psmdcp name to fix deterministic pack file-handle leak#7503
nkolev92 merged 3 commits into
devfrom
dev-nkolev92-14959

Conversation

@nkolev92

@nkolev92 nkolev92 commented Jun 23, 2026

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14959

Description

Deterministic pack leaks a file handle: PackageBuilder.CalcPsmdcpName() calls file.GetStream() for every file in the package and passes it to ReadAllBytes(), which only disposes the intermediate MemoryStream — the source stream returned by GetStream() (a File.OpenRead(...) for physical files) is never disposed.

Per OPC standards, the actual name just needs to be deterministic and it does not have to be per package unique, so using a hardcoded name is just fine.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

nkolev92 and others added 2 commits June 23, 2026 13:39
…e-handle leak

Fixes NuGet/Home#14959

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nkolev92 nkolev92 marked this pull request as ready for review June 23, 2026 21:41
@nkolev92 nkolev92 requested a review from a team as a code owner June 23, 2026 21:41
@nkolev92 nkolev92 requested review from donnie-msft and zivkan June 23, 2026 21:41
jebriede
jebriede previously approved these changes Jun 23, 2026

@jebriede jebriede left a comment

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.

Approving with suggestion.

Comment thread test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs Outdated
zivkan
zivkan previously approved these changes Jun 24, 2026
Comment thread src/NuGet.Core/NuGet.Packaging/PackageCreation/Authoring/PackageBuilder.cs Outdated
@nkolev92 nkolev92 dismissed stale reviews from zivkan and jebriede via 01930e8 June 25, 2026 00:21
@nkolev92 nkolev92 changed the title Dispose source stream in PackageBuilder.CalcPsmdcpName to fix deterministic pack file-handle leak Use hardcoded psmdcp name to fix deterministic pack file-handle leak Jun 25, 2026
@nkolev92 nkolev92 merged commit 5834c6b into dev Jun 25, 2026
20 of 21 checks passed
@nkolev92 nkolev92 deleted the dev-nkolev92-14959 branch June 25, 2026 16:18
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.

Deterministic pack leaks file handles (missing stream disposal in CalcPsmdcpName), breaking VMR signing

6 participants