Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception not thrown for ZipFile inside Blazor-Server Service #62231

Closed
BuchholzTim opened this issue Dec 1, 2021 · 7 comments
Closed

Exception not thrown for ZipFile inside Blazor-Server Service #62231

BuchholzTim opened this issue Dec 1, 2021 · 7 comments
Assignees
Labels
area-System.IO.Compression needs-author-action An issue or pull request that requires more info or actions from the author.

Comments

@BuchholzTim
Copy link

Description

Creating an archive of a folder (in blazor), which contains a named pipe in DotNet 6.0 via the ZipFile Class causes the program to block indefinitely long, without any kind of exception thrown.

  1. Create a Named Pipe in a Linux distribution with mkfifo (for me this happened while running my dotnet application inside a docker conatiner)
  2. Try to compress the directory containing the named pipe with ZipFile.CreateFromDirectory inside a Blazor-Server Service

Configuration

  • .NETCore 6.0.0
  • Hosted Blazor Webassembly (dotnet new blazorwasm -ho)

Other information

An Exception is thrown when I try to ZIP the same directory inside a simple Dotnet Console Application.

@scalablecory scalablecory transferred this issue from dotnet/core Dec 1, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Dec 1, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Dec 1, 2021

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

Issue Details

Description

Creating an archive of a folder (in blazor), which contains a named pipe in DotNet 6.0 via the ZipFile Class causes the program to block indefinitely long, without any kind of exception thrown.

  1. Create a Named Pipe in a Linux distribution with mkfifo (for me this happened while running my dotnet application inside a docker conatiner)
  2. Try to compress the directory containing the named pipe with ZipFile.CreateFromDirectory inside a Blazor-Server Service

Configuration

  • .NETCore 6.0.0
  • Hosted Blazor Webassembly (dotnet new blazorwasm -ho)

Other information

An Exception is thrown when I try to ZIP the same directory inside a simple Dotnet Console Application.

Author: BuchholzTim
Assignees: -
Labels:

area-System.IO.Compression, untriaged

Milestone: -

@adamsitnik
Copy link
Member

Hi @BuchholzTim

Are you sure that you are using mkfifo correctly? It's quite easy to get blocked using it.

Accodring to mkfifo man page:

Opening a FIFO for reading normally blocks
until some other process opens the same FIFO for writing, and
vice versa.

Moreover, the reading is finished when writer closes the file descriptor.

@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Dec 1, 2021
@adamsitnik adamsitnik self-assigned this Dec 1, 2021
@adamsitnik
Copy link
Member

An Exception is thrown when I try to ZIP the same directory inside a simple Dotnet Console Application.

I've tried to repro that, but I've failed. Here is the code that I've used:

public async Task CanZipNamedPipe()
{
    string destPath = Path.Combine(TestDirectory, "dest.zip");

    string subFolderPath = Path.Combine(TestDirectory, "subfolder");
    string fifoPath = Path.Combine(subFolderPath, "namedPipe");
    Directory.CreateDirectory(subFolderPath); // mandatory before calling mkfifo
    Assert.Equal(0, mkfifo(fifoPath, 438 /* 666 in octal */));

    byte[] contentBytes = { 1, 2, 3, 4, 5 };

    await Task.WhenAll(
        Task.Run(() =>
        {
            using FileStream fs = new (fifoPath, FileMode.Open, FileAccess.Write, FileShare.Read);
            foreach (byte content in contentBytes)
            {
                fs.WriteByte(content);
            }
        }),
        Task.Run(() =>
        {
            ZipFile.CreateFromDirectory(subFolderPath, destPath);

            using ZipArchive zippedFolder = ZipFile.OpenRead(destPath);
            using Stream unzippedPipe = zippedFolder.Entries.Single().Open();

            byte[] readBytes = new byte[contentBytes.Length];
            Assert.Equal(contentBytes.Length, unzippedPipe.Read(readBytes));
            Assert.Equal<byte>(contentBytes, readBytes);
            Assert.Equal(0, unzippedPipe.Read(readBytes)); // EOF
        }));
}

[DllImport("libc", SetLastError = true)]
private static extern int mkfifo(string path, int mode);

@BuchholzTim Could you please share more details (repro, stack trace)?

@ghost
Copy link

ghost commented Dec 2, 2021

This issue has been marked needs more info since it may be missing important information. Please refer to our contribution guidelines for tips on how to report issues effectively.

@ghost ghost added the no-recent-activity label Dec 16, 2021
@ghost
Copy link

ghost commented Dec 16, 2021

This issue has been automatically marked no recent activity because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no recent activity.

@ghost
Copy link

ghost commented Dec 30, 2021

This issue will now be closed since it had been marked no recent activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@ghost ghost closed this as completed Dec 30, 2021
@eiriktsarpalis eiriktsarpalis added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 19, 2022
@ghost ghost removed the no-recent-activity label Jan 19, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Feb 18, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Compression needs-author-action An issue or pull request that requires more info or actions from the author.
Projects
None yet
Development

No branches or pull requests

4 participants