Opened 21 months ago

Last modified 21 months ago

#5165 new defect

Zip files with comments trip assertion on game startup

Reported by: Teiresias Owned by: (none)
Priority: Nice to Have Milestone: Alpha 24
Component: Core engine Keywords:
Cc: Patch: Phab:D1511

Description

Placing a .zip file with a "zip file comment" below the $0AD-HOME/binaries/data/mods/public folder (so the pyrogenesis engine will scan it) causes a startup assertion to fire on all of my machines. On Windows, it said "(error while formatting error message)" while on Linux and FreeBSD it reports an assertion in archive_zip@500 has tripped.

The attached test.zip file trips the problem on my machines when placed e.g. in $0AD-HOME/binaries/data/mods/public/simulation/ai, and was built using the buildzipwithcomment.sh file inside that archive.

Note: The actual zip command was created using the zipnote utility. The tool crashed on both Linux and FreeBSD for me, so I fetched the source from ftp://ftp.info-zip.org/pub/infozip/src/zip30.tgz and debugged into it. It seems that the fclose(x); instruction in zipnote.c:666 is trying to close a file already closed in zipnote.c:552, and my stdlibs seem unforgiving to it. So I patched the zipnote.c and used that to create the comment. That's why the buildzipwithcomment.sh explicitly calls ./zipnote

(I actually encountered this problem during AI breeding as the jasmine archive is a commented zip file, and destilled it down to the test.zip)

Attachments (1)

test.zip (13.1 KB) - added by Teiresias 21 months ago.
Test archive with a comment, trips assertion archive_zip.cpp@500 and contains patched zipnote.c

Download all attachments as: .zip

Change History (6)

Changed 21 months ago by Teiresias

Attachment: test.zip added

Test archive with a comment, trips assertion archive_zip.cpp@500 and contains patched zipnote.c

comment:1 Changed 21 months ago by Teiresias

Fix is ready on my disk, will try to commit it into Phabricator.

comment:2 Changed 21 months ago by Teiresias

Milestone: Alpha 24Backlog

comment:3 Changed 21 months ago by Teiresias

Milestone: BacklogAlpha 24
Owner: set to (none)
Patch: Phab:D1511

comment:4 Changed 21 months ago by Teiresias

Fix has been put into Phabricator including description of problem cause and solution.

comment:5 Changed 21 months ago by Teiresias

Updated Phabricator item. The test.zip in Phab:D1511 now has been stripped from the zipnote.c sources to reduce the file size to a minimum.

On the trac ticket, I keep the original test.zip in place since the zipnote problem is independent of 0AD and the patch inside the .zip might be of help to somebody.

(Doubled fclose(x) is undefined behavior and may have worked in the past, but modern runtimes are likely to be less forgiving).

Note: See TracTickets for help on using tickets.