ZipArchive.TestArchive swallows important environmental exceptions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia da ZipFile.TestArchive e analizza come vengono gestite le eccezioni derivanti dalla verifica dell'archivio. Riproduci il comportamento con il progetto .NET Framework 4.8 fornito sotto pressione di memoria; il lavoro è completo quando una OutOfMemoryException viene propagata invece di essere convertita in un risultato false.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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;
}
}
}
- Lingua principale
- C#
- Stelle
- 3.9k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di icsharpcode/SharpZipLib
-
*no response* bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
icsharpcode/SharpZipLib#905 · 1 commento ·
-
bug bzip2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFile Apertaenhancement zip
Difficoltà 2/5 1-2 giorni Idoneità per principianti 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
icsharpcode/SharpZipLib#901 · 1 commento ·
-
*no response* bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
icsharpcode/SharpZipLib#894 · 1 commento ·
Tutte le issue di icsharpcode/SharpZipLib
Issue simili
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
apache/arrow-adbc#4809 ·
-
type/automation type/tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
microsoft/vscode-azurefunctions#5197 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
microsoft/microsoft-ui-reactor#1274 ·