dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.06k stars 4.69k forks source link

TarReader unable to parse header attribute number of archive generated in iOS #103734

Closed carlossanlop closed 2 months ago

carlossanlop commented 3 months ago

The runfo tool fails to read some tar files with the exception shown below. The jobID and workItem used are from a CI leg for iOS: job | log

The runfo tool is currently targeting net7.0 so I thought the tar bug was in that version. But I cloned the project, bumped the TargetFramework to net8.0, rebuilt, ran the command using the updated version, and I am still seeing the issue.

I'll share more details after I crack open the file.

runfo get-helix-payload --output=~/repos/helix/ --jobid=43c9e938-fc87-44bb-9596-74e8132ac106 --workitems=fbe6f019-aecc-43f1-880e-3a18d7079d7b
...
...
Payload cmake-3.28.0-macos-universal.tar.gz => /Users/carlos/repos/helix/~/repos/helix/correlation-payload/cmake-3.28.0-macos-universal.tar.gz
Unable to parse number.       
   at System.Formats.Tar.TarHelpers.ThrowInvalidNumber()
   at System.Formats.Tar.TarHelpers.ParseOctal[T](ReadOnlySpan`1 buffer)
   at System.Formats.Tar.TarHeader.TryReadCommonAttributes(Span`1 buffer, TarEntryFormat initialFormat)
   at System.Formats.Tar.TarHeader.TryReadAttributes(TarEntryFormat initialFormat, Span`1 buffer)
   at System.Formats.Tar.TarHeader.TryGetNextHeader(Stream archiveStream, Boolean copyData, TarEntryFormat initialFormat, Boolean processDataBlock)
   at System.Formats.Tar.TarReader.TryProcessExtendedAttributesHeader(TarHeader extendedAttributesHeader, Boolean copyData, TarHeader& actualHeader)
   at System.Formats.Tar.TarReader.TryGetNextEntryHeader(Boolean copyData)
   at System.Formats.Tar.TarReader.GetNextEntry(Boolean copyData)
   at System.Formats.Tar.TarFile.ExtractToDirectoryInternal(Stream source, String destinationDirectoryPath, Boolean overwriteFiles, Boolean leaveOpen)
   at DevOps.Util.HelixServer.<>c__DisplayClass9_0.<<GetHelixPayloads>g__DownloadAndExtractFile|0>d.MoveNext() in /home/runner/work/runfo/runfo/DevOps.Util/HelixServer.cs:line 164
--- End of stack trace from previous location ---
   at DevOps.Util.HelixServer.GetHelixPayloads(String jobId, List`1 workItems, String downloadDir, Boolean ignoreDumps, Boolean resume, Boolean extract) in /home/runner/work/runfo/runfo/DevOps.Util/HelixServer.cs:line 94
   at Runfo.RuntimeInfo.GetHelixPayload(IEnumerable`1 args) in /home/runner/work/runfo/runfo/runfo/RuntimeInfo.cs:line 1125
   at Runfo.Program.<>c__DisplayClass0_0.<<Main>g__RunCommand|0>d.MoveNext() in /home/runner/work/runfo/runfo/runfo/Program.cs:line 91
--- End of stack trace from previous location ---
   at Runfo.Program.Main(String[] args) in /home/runner/work/runfo/runfo/runfo/Program.cs:line 54
   at Runfo.Program.Main(String[] args) in /home/runner/work/runfo/runfo/runfo/Program.cs:line 58
dotnet-policy-service[bot] commented 3 months ago

Tagging subscribers to this area: @dotnet/area-system-formats-tar See info in area-owners.md if you want to be subscribed.

tmds commented 3 months ago

From the stacktrace it looks probable that https://github.com/dotnet/runtime/pull/101172 will fix this.

jeffhandley commented 2 months ago

@tmds or @carlossanlop -- Do we know if #101172 addressed this yet?

carlossanlop commented 2 months ago

I was able to repro the problem in .NET 8.0 by downloading the problem file directly and trying to open it using GZipStream + TarFile.ExtractToDirectory: https://netcorenativeassets.blob.core.windows.net/resource-packages/external/macos/cmake/cmake-3.28.0-macos-universal.tar.gz

I was also able to confirm that the problem is gone with the latest bits in main, @tmds PR fixed it.

The fix was merged to main on June 25th, but the Preview6 snap happened on June 19th, so this should be fixed in Preview7.