Opened 6 years ago

Closed 3 years ago

#5165 closed defect (fixed)

Zip files with comments trip assertion on game startup

Reported by: Teiresias Owned by: Stan
Priority: Nice to Have Milestone: Alpha 24
Component: Core engine Keywords:
Cc: Patch: Phab:D1511, Phab:D613

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 6 years ago.
Test archive with a comment, trips assertion archive_zip.cpp@500 and contains patched zipnote.c

Download all attachments as: .zip

Change History (10)

by Teiresias, 6 years ago

Attachment: test.zip added

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

comment:1 by Teiresias, 6 years ago

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

comment:2 by Teiresias, 6 years ago

Milestone: Alpha 24Backlog

comment:3 by Teiresias, 6 years ago

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

comment:4 by Teiresias, 6 years ago

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

comment:5 by Teiresias, 6 years ago

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

comment:6 by Silier, 4 years ago

Owner: (none) removed

comment:7 by Stan, 3 years ago

Patch: Phab:D1511Phab:D1511, Phab:D613

I just realised this is the issue I have been experiencing every time I install a mod now...

comment:8 by wraitii, 3 years ago

In 24234:

Remove UniqueRange custom code in favour of unique_ptr

UniqueRange was a unique_ptr replacement with a few tweaks (such as a compulsory custom deleter). Its features are not really used, it contains outdated atomic calls, and it blocks D1511, thus it is removed.

Refs #5165

Differential Revision: https://code.wildfiregames.com/D613

comment:9 by Stan, 3 years ago

Owner: set to Stan
Resolution: fixed
Status: newclosed

In 24368:

Fix zip with comments triggering assertion on game startup
Fixes #5165

Patch by: @Teiresias

Differential Revision: https://code.wildfiregames.com/D1511

Note: See TracTickets for help on using tickets.