loresoft / msbuildtasks

The MSBuild Community Tasks Project is an open source project for MSBuild tasks.
BSD 2-Clause "Simplified" License
946 stars 272 forks source link

Zip task hangs with latest Ionic.Zip.Reduced #2

Open mkarpuk opened 12 years ago

mkarpuk commented 12 years ago

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.

pwelter34 commented 11 years ago

Not able to reproduce this error.

danjagnow commented 11 years ago

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.

blackboy69 commented 11 years ago

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

mkarpuk commented 11 years ago

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

michael-baker commented 11 years ago

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.

derkyjadex commented 11 years ago

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 commented 11 years ago

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

ctigeek commented 11 years ago

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.

dblock commented 10 years ago

confirm workaround that @ctigeek suggested, worked for me too

musicmen commented 9 years ago

workaround did solve the problem for me too, thx!

ghost commented 9 years ago

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...)

NuKiNuKe commented 9 years ago

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

AndrewBennet commented 7 years ago

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.

haf commented 7 years ago

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

AndrewBennet commented 7 years ago

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 commented 7 years ago

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!

pwelter34 commented 7 years ago

I'll push today.