msbuildtasks icon indicating copy to clipboard operation
msbuildtasks copied to clipboard

Zip task hangs with latest Ionic.Zip.Reduced

Open mkarpuk opened this issue 13 years ago • 17 comments

Recently I have updated MSBuild.Community.Tasks library to the last version in my build process and found out that Zip task which compressed deployment package hangs (it displays that all files were added and stay in that state at least for 2 hrs). It worked if I run zip separately from build process, however.

I wasn't managed to figure out the problem, but using old version of Ionic.Zip (v1.9.1.5 instead of Ionic.Zip.Reduced v 1.9.1.8) solved the issue.

mkarpuk avatar May 25 '12 07:05 mkarpuk

Not able to reproduce this error.

pwelter34 avatar Jul 09 '12 22:07 pwelter34

I downloaded the library today specifically for the Zip task, and I'm also experiencing that it hangs when it gets to the Zip step. It created a file named DotNetZip-mcgziv5n.tmp which quickly went to 6,189 KB and then... at least 10 minutes of nothing. I had to cancel the build, and repeating the process later produced the same result.

danjagnow avatar Aug 17 '12 11:08 danjagnow

This needs to be reopened! I am having the same issue! zip hangs in TFS Build, but works fine in a separate process! This leaves a file named "DotNetZip-lk2cvgvz.tmp" that doesn't grow

blackboy69 avatar Aug 20 '12 17:08 blackboy69

Hi, folks! If you could send a project on which you were able to reproduce the issue, I believe it will help a lot to figure out a problem. Unfortunately I can't publish sources where task hangs (they are proprietary), I tried to reproduce on a small test project, but with no success. I could just confirm, that problem occurred only if Zip task called at the end of build process (if sources are compiled as one step and MSBuild called once again with just Zip task, it works). This could be one more workaround. It does not connected with TFS Build, since we are using Hudson, and the same behavior was observed on my local machine from pure commandline call of MSBuild

mkarpuk avatar Aug 21 '12 07:08 mkarpuk

The problem appears to be a deadlock inside Ionic.Zlib.ParallelDeflateOutputStream.EmitPendingBuffers. A thread will get stuck on _newlyCompressedBlob.WaitOne() forever which is why the process hangs.

michael-baker avatar Sep 26 '12 09:09 michael-baker

I'm also having this problem with a particular file. As far as I can tell, there seems to be a race condition. Sometimes the ZIP file will be created, but it will be corrupt, other times it just hangs. There seems to be a bug for this already, http://dotnetzip.codeplex.com/workitem/14252. Changing ZipLevel doesn't do anything for me.

I do have a small test project that reproduces the issue, but it uses an assembly that I can't really give out. I will try to break it down further and send it out if I get a chance. In the meantime, I've added a ParallelCompression property to the Zip task to work around this issue. I can't push the patch from where I am now, but will do tomorrow morning.

derkyjadex avatar Oct 10 '12 16:10 derkyjadex

Ok, I've added a pull request for my work around, no idea how to attach it to this issue.

derkyjadex avatar Oct 11 '12 08:10 derkyjadex

I had the same issue, and this change worked. One thing I had to figure out, that isn't obvious from the discussion above, is that you have to add the parameter ParallelCompression="false" to the zip task for the fix to take effect.

ctigeek avatar Jan 27 '13 23:01 ctigeek

confirm workaround that @ctigeek suggested, worked for me too

dblock avatar Nov 14 '13 21:11 dblock

workaround did solve the problem for me too, thx!

musicmen avatar Jul 16 '14 18:07 musicmen

We're not getting the task/build hanging, but in our case it repeatedly produced a corrupt zip file (on 1.4.0.88); always with the same file corrupt inside the zip. Disabling ParallelCompression (thanks @ctigeek !) also worked around this problem.

Our specific issue seems almost certainly related to https://dotnetzip.codeplex.com/workitem/14087 (file is an exact multiple of 64kB which breaks parallel deflate) but highlights that perhaps parallel compression should be disabled by default in msbuildtasks; especially as Ionic seems unmaintained now and this bug is pretty dangerous for build automation primarily used to produce deployable artifacts and very hard to pin down.

Alternative 1, perhaps given it is apparently unmaintained with serious defects it's time to abandon Ionic? Alternative 2, since Ionic is built and distributed internally inside the tasks, perhaps the suggested patch fix on the linked issue could be applied and rebuilt here? (not ideal...)

ghost avatar Jan 22 '15 04:01 ghost

The ParallelCompression workaround did solve the problem for me! Thank you!

NuKiNuKe avatar May 07 '15 15:05 NuKiNuKe

I've created a fork where I've replaced the DotNetZip with a better maintained fork. In particular, it fixes the issue with ParallelDeflateOutputStream, and allows use of ParallelCompression without fear of creating a corrupt archive.

AndrewBennet avatar Oct 27 '16 09:10 AndrewBennet

Just saying hi. Followed notifications a bit too eagerly =). Feel free to PR to that fork and it'll be merged.

haf avatar Oct 27 '16 13:10 haf

Hi :) I was referring to a pull request to this project (msbuildtasks), where I replaced the original DotNetZip, with your fork. (The pull request is currently open.) Thanks!

AndrewBennet avatar Oct 27 '16 13:10 AndrewBennet

I think this issue is resolved with the recent merged pull request. Would it be possible to update the nuget package? (I don't know what the standard release cycle is for this repository). Thanks a lot!

AndrewBennet avatar Oct 28 '16 14:10 AndrewBennet

I'll push today.

pwelter34 avatar Oct 28 '16 15:10 pwelter34