Ticket #2171 (new bug)

Opened 10 years ago

Last modified 10 years ago

Archive.Zip Errors

Reported by: Eclesia Owned by:
Priority: normal Milestone:
Component: library Version: master
Severity: medium Keywords:
Cc: Eclesia, fperrad, whiteknight Language:
Patch status: Platform: all

Description

The current Zip class fails to create a simple archive , bug can be reproduce with the following winxed code :

var archive = new ["Archive","Zip"];
archive.addFile("README.txt");
archive.writeToFileNamed("output.zip");

error message is :

current instr.: 'parrot;Archive;Zip;Base;pack_V' pc 145 (runtime/parrot/library/Archive/Zip.pir:104)
called from Sub 'parrot;Archive;Zip;Member;_writeLocalFileHeader' pc 807 (runtime/parrot/library/Archive/Zip.pir:305)
called from Sub 'parrot;Archive;Zip;Member;_writeToFileHandle' pc 1802 (runtime/parrot/library/Archive/Zip.pir:528)
called from Sub 'parrot;Archive;Zip;writeToFileHandle' pc 2509 (runtime/parrot/library/Archive/Zip.pir:796)
called from Sub 'parrot;Archive;Zip;writeToFileNamed' pc 2416 (runtime/parrot/library/Archive/Zip.pir:762)
called from Sub 'parrot;model_parser;FileUtilities;readZip' pc 76 (target-pir/model_parser/FileUtilities.pir:0) (lib-0/model_parser/FileUtilities.wx:27)
called from Sub 'main' pc 132 (target-pir/Executor.pir:78) (lib-0/Executor.wx:79)

Change History

follow-up: ↓ 4   Changed 10 years ago by bubaflub

Here is a minimal PIR test case:

.sub 'main' :main
    .local pmc archive
    load_bytecode 'Archive/Zip.pir'
    archive = new ["Archive";"Zip"]
    archive.'addFile'("README.txt")
    archive.'writeToFileNamed'("output.zip")
.end

If README.txt doesn't exist I get a very unhelpful error:

Null PMC access in find_method('_usesFileNamed')
current instr.: 'parrot;Archive;Zip;writeToFileNamed' pc 2365 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:720)
called from Sub 'main' pc 21 (test.pir:6)

If it does I still get the same error as above:

error:no member name given
Null PMC access in get_integer()
current instr.: 'parrot;Archive;Zip;Base;pack_V' pc 145 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:87)
called from Sub 'parrot;Archive;Zip;Member;_writeLocalFileHeader' pc 807 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:284)
called from Sub 'parrot;Archive;Zip;Member;_writeToFileHandle' pc 1802 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:507)
called from Sub 'parrot;Archive;Zip;writeToFileHandle' pc 2509 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:760)
called from Sub 'parrot;Archive;Zip;writeToFileNamed' pc 2416 (/usr/local/lib/parrot/3.5.0-devel/library/Archive/Zip.pir:729)
called from Sub 'main' pc 21 (test.pir:6)

follow-up: ↓ 3   Changed 10 years ago by jkeenan

  • cc Eclesia, fperrad, whiteknight added
  • reporter changed from whiteknight to Eclesia

Eclesia:

whiteknight indicated he opened this ticket following your report, so I'm switching the "Reporter" to you.

Does commit a39491c178b address your concerns?

Thank you very much.

kid51

in reply to: ↑ 2   Changed 10 years ago by Eclesia

kid51 : thanks for trying to fix it. The archive seems fine. but the content is actually corrupted. I can't extract anything from it.

in reply to: ↑ 1   Changed 10 years ago by jkeenan

Replying to bubaflub:

Here is a minimal PIR test case:

I tried this case today. Here are my results:

$ cat ziptest.pir
# Copyright (C) 2006-2009, Parrot Foundation.
# $Id: skeleton.pir 38369 2009-04-26 12:57:09Z fperrad $

.sub 'main' :main
    .local pmc archive
    load_bytecode 'Archive/Zip.pir'
    archive = new ["Archive";"Zip"]
    archive.'addFile'("README.txt")
    archive.'writeToFileNamed'("output.zip")
.end


# Local Variables:
#   mode: pir
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:

$ ls README.txt
ls: README.txt: No such file or directory

$ ./parrot ziptest.pir 

$ ls output*   
output.zip

$ unzip -p output.zip 
warning [output.zip]:  zipfile is empty

$ echo "This is a dummy README.txt file" > README.txt

$ cat README.txt 
This is a dummy README.txt file

$ ./parrot ziptest.pir 

$ unzip -l output.zip
Archive:  output.zip
  Length     Date   Time    Name
 --------    ----   ----    ----
       32  08-08-11 18:32   README.txt
 --------                   -------
       32                   1 file

$ unzip -p output.zip 
  error:  invalid compressed data to inflate README.txt
  

So, superficially, I was able to zip, but I was unable to unzip successfully.

kid51

  Changed 10 years ago by fperrad

I missed something with the COMPRESSION_DEFLATED mode when I ported the Perl5 module Archive::Zip 1.30.

Try to revert  https://github.com/parrot/parrot/commit/8df7a60e61fbb927696f8889e2e453e98ab24a9c#runtime/parrot/library/Archive/Zip.pir

The COMPRESSION_STORED mode works well.

Note: See TracTickets for help on using tickets.