Skip to content

Pre-zip xplat dump payloads to bypass Helix SDK 2 GB MemoryStream cap#127871

Open
max-charlamb wants to merge 1 commit intodotnet:mainfrom
max-charlamb:fix/cdac-xplat-dump-payload-archive
Open

Pre-zip xplat dump payloads to bypass Helix SDK 2 GB MemoryStream cap#127871
max-charlamb wants to merge 1 commit intodotnet:mainfrom
max-charlamb:fix/cdac-xplat-dump-payload-archive

Conversation

@max-charlamb
Copy link
Copy Markdown
Member

Note

This PR was authored with assistance from GitHub Copilot.

Problem

  • "" + CdacXPlatDumpTest + "" + Helix work items fail intermittently with:

    System.IO.IOException: Stream was too long.
    at System.IO.MemoryStream.set_Capacity(Int32 value)

The Helix SDK's <PayloadDirectory> code path (DirectoryPayload.UploadAsync) zips the source directory into a MemoryStream before uploading. MemoryStream's backing array is capped at int.MaxValue (~2 GiB), so per-platform dump payloads that approach that size fail.

Fixes #127859.

Fix

Pre-zip each per-platform dump directory with MSBuild's built-in ZipDirectory task and ship the resulting .zip via <PayloadArchive> instead of <PayloadDirectory>.

  • ZipDirectory calls ZipFile.CreateFromDirectory, which writes the archive directly to a FileStream -- no 2 GiB cap.
  • The Helix SDK's ArchivePayload (selected by <PayloadArchive>) uses File.OpenRead and streams the existing zip to blob storage without any in-memory buffering.
  • CompressionLevel="Fastest" keeps the local zip step cheap; dump files don't compress meaningfully anyway.

This is the same pattern already used in src/tests/Common/helixpublishwitharcade.proj.

Validation

  • Verified locally with the ZipDirectory + target-batching pattern against fake per-platform directories: produces one .zip per platform as expected with Overwrite="true".
  • Will also be validated by re-running runtime-diagnostics with cdacDumpTestMode=xplat against this PR.

The Helix SDK's <PayloadDirectory> code path (DirectoryPayload.UploadAsync)
zips the directory into a MemoryStream before upload. MemoryStream's backing
array is capped at int.MaxValue (~2 GiB), so per-platform dump payloads that
approach that size fail in CdacXPlatDumpTest with:

    System.IO.IOException: Stream was too long.
       at System.IO.MemoryStream.set_Capacity(Int32 value)

Switch the cDAC xplat dump tests to pre-zip each per-platform dump directory
with the MSBuild ZipDirectory task and ship the resulting .zip via
<PayloadArchive>. ArchivePayload uses File.OpenRead and streams directly to
blob storage, with no in-memory buffering. CompressionLevel=Fastest keeps
the local zip step cheap; dumps don't compress meaningfully anyway.

This follows the same pattern already used in
src/tests/Common/helixpublishwitharcade.proj.

Fixes dotnet#127859

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the cDAC x-plat dump Helix submission project to avoid intermittent Helix SDK failures caused by the SDK’s <PayloadDirectory> path building a ZIP in a MemoryStream (which is capped at ~2 GiB). It pre-creates per-platform ZIPs on disk and ships them via <PayloadArchive> so upload can stream from a FileStream.

Changes:

  • Pre-zip each per-platform dump directory using MSBuild’s ZipDirectory task.
  • Switch Helix work items from <PayloadDirectory> to <PayloadArchive> pointing at the prebuilt ZIP.
  • Update inline documentation to explain the rationale and the 2 GiB cap being avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci-scan] Test failure: CdacXPlatDumpTest IOException: Stream was too long in runtime-diagnostics (pipeline 309)

3 participants