Crash when compressing multiple files concurrently


Hi. I have a Windows Service that creates zip files on demand in a multi-threaded fashion. Each thread executes the following lines of code:
SevenZipCompressor comp = new SevenZipCompressor();
comp.ArchiveFormat = OutArchiveFormat.Zip;
comp.DirectoryStructure = true;
comp.CompressDirectory(zipFolder, zipFolder + ".zip");
Whenever multiple threads attempt to execute the code above concurrently, the service crashes. No exception is thrown, the service just stops. Can anyone help me troubleshoot this issue?
  • Mark


markhor wrote May 11, 2010 at 6:51 AM

I have just checked multi-threaded compression test in SevenZipTest, it works ok. Try to conduct this test.

If it works for you, too, try to use logging to determine the actual place where the service falls. Pay special attention to LibraryManager.cs methods
public static IInArchive InArchive
public static IOutArchive IOutArchive

mmiretsky wrote May 11, 2010 at 6:48 PM

I am not sure that we are talking about the same thing here. I am not talking about multi-threaded compression that is set by using CustomParameters.Add("mt", "on"). I am talking about multiple threads within the same application trying to compress different files (each thread in my application is compressing a different file).

  • Mark

markhor wrote May 12, 2010 at 7:58 AM

Yes, we are talking about the same thing. Take a look at SevenZipTest->Program.cs->#region Multi-threaded compression test

...and you will see words like Thread, Start and Join.

mmiretsky wrote May 12, 2010 at 5:47 PM

Hmm... Very interesting. I couldn't find SevenZipTest, so I wrote my own test program (a console application) to test multi-threaded compression and it worked fine. However, it still doesn't work in my Windows Service that exposes a WCF endpoint and creates zip files as part of processing a WCF request. Very strange. I have found a workaround, so I am all set, but if you could try this in your environment, I would be curious to know if it works for you.

markhor wrote May 17, 2010 at 7:04 AM

You could strip everything from your service except the compression part and attach here the code (or send by mail), I will take a look and test it.

wrote Dec 21, 2011 at 10:28 PM

scottlerch wrote Dec 21, 2011 at 11:37 PM

I can recreate this problem every time using several threads compressing various files at once on a machine with 8 hardware threads. Same issue as 9786, 8486. See my comments in 9786.

wrote Feb 22, 2013 at 1:16 AM