ZipArchive.TestArchive swallows important environmental exceptions
まだ誰も着手していません。
評価
調査の方向性
ZipFile.TestArchive から開始し、アーカイブの検証で発生した例外がどのように処理されるかを確認します。提供された .NET Framework 4.8 プロジェクトをメモリ負荷の高い状況で使って動作を再現します。OutOfMemoryException が false の結果に変換されずに伝播すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Steps to reproduce
Call ZipFile.TestArchive when the application is under severe memory pressure.
Expected behavior
An OutOfMemoryException is thrown by the runtime and leaks out of SharpZipLib.
Actual behavior
SharpZipLib swallows the OutOfMemoryException and TestArchive returns false, leading people to believe that there is a problem with the ZIP file, rather than the runtime.
Version of SharpZipLib
v1.3.3.
Obtained from (only keep the relevant lines)
Package installed using NuGet
Repro case:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net48</TargetFramework>
<RootNamespace>TestZipFile</RootNamespace>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<Platform>x86</Platform>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.3.3" />
</ItemGroup>
</Project>
using ICSharpCode.SharpZipLib.Zip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace TestZipFile
{
public static class Program
{
public static int Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine($"Usage: test-zip.exe <path to zip file>");
return -1;
}
Console.WriteLine($"Process architecture: {RuntimeInformation.ProcessArchitecture}");
using var fs = File.OpenRead(args[0]);
using var zip = new ZipFile(fs);
var list = new List<byte[]>(capacity: 20);
var increment = 1_000_000_000;
Console.WriteLine("Reserving memory...");
while (true)
{
try
{
var data = new byte[increment];
list.Add(data);
}
catch (OutOfMemoryException)
{
if (increment > 10_000)
{
increment = increment / 10;
}
else
{
break;
}
}
}
Console.WriteLine($"Reserved {list.Sum(static x => x.Length)} bytes.");
AppDomain.CurrentDomain.FirstChanceException += (sender, e) =>
{
if (e.Exception is OutOfMemoryException)
{
list.Clear();
GC.Collect();
}
};
Console.WriteLine($"Verifying zip...");
Console.WriteLine("---");
Console.WriteLine();
var result = zip.TestArchive(testData: true, TestStrategy.FindAllErrors, static (status, message) => { });
GC.KeepAlive(list);
Console.WriteLine("---");
Console.WriteLine($"Result: {(result ? "PASS" : "FAIL")}");
return result ? 0 : -2;
}
}
}
- 主要言語
- C#
- スター
- 3.9k
- フォーク
- 1k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/SharpZipLib のほかの issue
-
*no response* bug
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
icsharpcode/SharpZipLib#905 · コメント 1 件 ·
-
bug bzip2
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFile オープンenhancement zip
難易度 2/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 32/100
icsharpcode/SharpZipLib#901 · コメント 1 件 ·
-
*no response* bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
icsharpcode/SharpZipLib#894 · コメント 1 件 ·
icsharpcode/SharpZipLib の issue をすべて見る
似ている issue
-
bug frontend good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
NavigationViewItemAutomationPeer implements IInvokeProvider but never advertises the Invoke pattern オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
unoplatform/uno#24629 ·
-
agentic-workflows Needs: Triage :mag: State: In-PR
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Type: enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
apache/arrow-adbc#4809 ·