gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

zzcat.exe built by MinGW segfaults when fed with a particular name #36

Open mojca opened 6 years ago

mojca commented 6 years ago

While running make check I realized that zzcat.exe is a bit picky about the name you feed it:

$ ls
Makefile  test.zip  zzipself.exe  zzipself.o  zzipsetstub.exe  zzipsetstub.o

$ ../bins/zzcat.exe test
test: No such file or directory

$ ../bins/zzcat.exe test/foo
Segmentation fault

$ ../bins/zzcat.exe testx/foo
testx/foo: No such file or directory

This might be related to changes done for #6, but that's a speculation.

gdraheim commented 6 years ago

That's what it should be like - when "test.zip" does exist then "test/foo" shall extract "foo" from test.zip. If it does not exist, then try to access a normal file.

The segfault should be analysed.

gdraheim commented 6 years ago

by the way, how does "test.zip" look like?

This should work:

unzip -c test.zip README
mojca commented 6 years ago

OK, I need to admit that the syntax is super strange in that case. I'm also not 100% sure if my patch is correct then.

$ unzip -c test.zip README
Archive:  test.zip
  inflating: README
PROJECT
  The zziplib provides read access to zipped files in a zip-archive,
  using compression based solely on free algorithms provided by zlib.
  It also provides a functionality to overlay the archive filesystem
  with the filesystem of the operating system environment.
...
gdraheim commented 6 years ago

Well, that looks like the test.zip is OK.

As for zzcat.... that was one of the early test programs. The zziplib had its first success among game developers that were compressing map data. During development they had all files on disk (plain files) and they were shipping off a (possibly obfuscated) zip to customers.

This feature was adopted by other people, possibly web site builders and such. But not everyone requires it and you can use the library without that pecularity.

gdraheim commented 6 years ago

Sadly, I have not worked with MingW for quite a while. Is it possible for you to run the test through gdb to get me full stacktrace?

mojca commented 6 years ago

I'm not really a Windows person, neither am I too familiar with gdb. I tried, but I'm stuck:

$ gdb zzcat.exe
GNU gdb (GDB) 8.0.1
[...]
Reading symbols from zzcat.exe...(no debugging symbols found)...done.
(gdb) b main
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) r ../test/test/README
Starting program: C:\msys32\home\me\zziplib\build\bins\zzcat.exe ../test/test/README
[New Thread 860.0x1254]
[Inferior 1 (process 860) exited with code 030000000005]

I made sure that zzcat.exe was compiled with -g, but I have no clue how to set breakpoints in multi-threaded apps in command line etc.

acotty commented 4 years ago

I have install MSYS 2 and have only installed mingw-w64* packages. I have installed the LIBZZIP package using: pacman -S mingw-w64-x86_64-libzip zip Details of the package are: https://packages.msys2.org/package/mingw-w64-x86_64-zziplib?repo=mingw64

When I run GDB I get the following segmentation error as per mojca above. $ gdb --args /mingw64/bin/zzcat.exe test/test.png GNU gdb (GDB) 8.3.1 Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from C:/msys64/mingw64/bin/zzcat.exe... (No debugging symbols found in C:/msys64/mingw64/bin/zzcat.exe) (gdb) r Starting program: C:\msys64\mingw64\bin\zzcat.exe test/test.png [New Thread 8564.0x1e98] [New Thread 8564.0x44d8] [New Thread 8564.0x3ab8]

Thread 1 received signal SIGSEGV, Segmentation fault. 0x0000000061d01433 in ?? () from C:\msys64\mingw64\bin\libzzip-0-13.dll (gdb)

I have tried to build the libzzip from source, but the ./configure produces a non working makefile. The makefile is atatched. The makefile error is: $ mingw32-make Makefile:825: target 'dist-all' given more than once in the same rule sh: ../uses/config.guess: No such file or directory MAKE : 1 * all-all /usr/bin/sh: line 9: make: command not found

The makefile produced is: Makefile.txt mingw32-make: *** [Makefile:385: all-all] Error 127

I have also tried to configure using the following and it also produced a bad makefile: ./configure --host=x86_64-w64-mingw64 --build=x86_64-w64-mingw64 --target=x86_64-w64-mingw64 I also tried the following, but is also failed: mingw32-build --host=x86_64-w64-mingw64 --build=x86_64-w64-mingw64 --target=x86_64-w64-mingw64 BTW I have built the library under CYGWIN, but the app I am using the libzzip in is an opengl app, so under CYGWIN I need to start X11 and it becomes a PITA to have so many things running. Hopefully I can get the app running natively using mingw64 (I have my app compiling and starting to run, but is also segfaults in the same DLL when using the zzip_file = zzip_fopen (file, mode); line in SDL_rwops_zzip.c file).

acotty commented 4 years ago

Stumbled on this info, which could explain how to fix the library under MINGW if only I could build it: https://tug.org/pipermail/tlbuild/2013q1/002440.html

gdraheim commented 4 years ago

Latest release was tested with cmake.