Mandasy / zip-framework

Automatically exported from code.google.com/p/zip-framework
Other
0 stars 0 forks source link

fread of FILE* returned from entryNamed: never returns #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am using zip-framework to uncompress a .zip file downloaded using 
NSURLDownload. The 
issue I am seeing is that if I start an uncompress from the downloadDidFinish: 
delegate method 
the following hangs whether it is run on the main thread or in a separate 
thread:

ZipArchive* lZipArchive = [ZipArchive archiveWithFile:zipFilePath];
NSArray* lEntries = [lZipArchive entries];

FILE* lResourceAttributes = [lZipArchive entryNamed:[@"__MACOSX/._rgb2"];

Byte lHeader[40];
size_t lResult = fread(&lHeader, sizeof(char), sizeof(lHeader), 
lResourceAttributes);

the code above is attempting to read the AppleDouble header from a zip file 
created by archive 
helper.

When I look at this I can see that downloadDidFinish: is executed on the main 
thread by       
performSelectorOnMainThread:withObject:waitUntilDone: which makes sense as 
NSURLDownload 
uses threading. 

I have attached a Sample taken on my machine (Tiger 10.4.11). The thread that 
hangs is the last 
one which was just created to handle the unzip. It looks to me to be a race 
condition.

Thanks for taking a look.

Original issue reported on code.google.com by nbead...@gmail.com on 22 Apr 2008 at 11:24

Attachments:

GoogleCodeExporter commented 8 years ago
I encountered this as well. I think that it might happen when trying to read a 
single
uncompressed entry in an otherwise compressed zip file, since I was able to 
read the
other (compressed) entries fine, but the uncompressed one would cause the hang 
to
occur. Some file formats save header entries uncompressed to ease scanning for
external tools, and it sounds like that might be the same phenomenon you 
encountered.

Original comment by mprud...@gmail.com on 27 Jun 2008 at 6:34

GoogleCodeExporter commented 8 years ago
I ended up using the minizip contribution to zlib in my own NSThread. Not much 
trickier than using this zip-
framework and it has worked in all cases for me.

Original comment by nbead...@gmail.com on 27 Jun 2008 at 5:31

GoogleCodeExporter commented 8 years ago
Reading uncompressed files is indeed not supported. I will fix this in an 
upcoming version.

Original comment by joris.kl...@gmail.com on 22 Jan 2009 at 11:39

GoogleCodeExporter commented 8 years ago
Anybody know, how to fix this issues?

Original comment by tooh...@gmail.com on 23 Nov 2009 at 2:32