howto debug unzip under cygwin?

Thomas L Roche <tlroche-r/[email protected]> Thu, 12 Feb 2004 14:51:44 -0500
Newsgroups gmane.comp.archivers.info-zip
Message-ID <OFEA4CAE32.F12B04A4-ON85256E38.006C7375-85256E38.006D1B62@us.ibm.com>
Could someone provide me with pointers toward debugging (what I
believe to be a cygwin problem, manifesting itself as) an unzip
problem? What I mean:

After recently upgrading cygwin, I can no longer unzip files that I
formerly could. (To clarify: I save the files after downloading. I
have a specific file that I unzipped and used to create a product,
using cygwin-1.5.5-1. The same file fails to unzip under cygwin-
1.5.7-1, as do more recent files created by the same build process.
FWIW the archives involved are ~= 1.5GB, and contain ~100k files.)
Failures are like

>> >   inflating:
>> 
/d/eclipse/builds/20040121_1953-WB213-AD-V512D-00/eclipse/plugins/com.ibm.etools.j2ee.ui/build/pluginBuild/commonbld/com/ibm/etools/ejb/ui/presentation/EJBEditorOutlineContentProvider.class

>> >     735 [main] unzip 1820 cmalloc: cmalloc returned NULL
>> > error:  zipfile probably corrupt (segmentation violation)

I posted to [email protected]

Thomas L Roche 02/11/2004 06:08 PM
>>> it seems pretty clear to me that something "down deep" in the base
>>> broke after 1.5.5-1:

>>> 0 both character-mode (e.g. unzip) and X (e.g. emacs) apps are
>>>   broken

>>> 1 inputs that worked in 1.5.5-1 don't work now

>>> 2 failures are intermittent and apparently random

>>> 3 error messages suggest malloc problems 

>>> Am I missing something?

Christopher Faylor Wed, 11 Feb 2004 18:45:42 -0500
>> Actual debugging of the problem, with a debugger?

Fair enough, but I haven't coded or debugged C/C++ in 6 years. Seeking
help, I was told

Igor Pechtchanski 02/11/2004 09:20:22 PM:
> Make sure you have the "tar", "patch", "gcc", "gcc-g++", "gdb", and
> "make" packages installed (via Cygwin's setup).

> Download the unzip source (e.g., "wget ftp://mirrors.rcn.
> net/pub/sourceware/cygwin/release/unzip/unzip-5.50-5-src.tar.bz2").

> Untar the unzip source to /usr/src (e.g., "tar -C /usr/src -xjf
> unzip-5.50-5-src.tar.bz2").

> Enter that directory and run the prep, conf, build, and install
> steps of the script (e.g., "cd /usr/src && ./unzip-5.50-5.sh prep &&
> . /unzip-5.50-5.sh conf && ./unzip-5.50-5.sh build &&
> ./unzip-5.50-5.sh install").

> You should now have a debug build of unzip sitting in
> /usr/src/unzip-5.50/.inst (the maintainer graciously set it up to
> build with debugging by default)

Perhaps not: I do

wget -O - 
ftp://mirrors.rcn.net/pub/sourceware/cygwin/release/unzip/unzip-5.50-5-src.tar.bz2 
| tar -C /usr/src -xj
cd /usr/src && ./unzip-5.50-5.sh prep && ./unzip-5.50-5.sh conf && 
./unzip-5.50-5.sh build && ./unzip-5.50-5.sh install
cd /usr/src/unzip-5.50/.inst && gdb --args ./usr/bin/unzip.exe 
/d/eclipse/zips/wsa-jdk-20040210_1925-WB213-AD-V512D-W5.zip

and get

> GNU gdb 2003-09-20-cvs (cygwin-special)
> Copyright 2003 Free Software Foundation, Inc.

> GDB is free software, covered by the GNU General Public License, and
> you are welcome to change it and/or distribute copies of it under
> certain conditions.

> Type "show copying" to see the conditions.

> There is absolutely no warranty for GDB. Type "show warranty" for
> details.

> This GDB was configured as "i686-pc-cygwin"...(no debugging symbols
> found)...

Igor Pechtchanski 02/11/2004 09:20:22 PM:
> Set a breakpoint at the failing line (fileio.c, line 146) and start 
> debugging :-)

I do

(gdb) break fileio.c:146
> No symbol table is loaded.  Use the "file" command.
(gdb) file ./usr/bin/unzip.exe
> Reading symbols from ./usr/bin/unzip.exe...(no debugging symbols
> found)...done.

What do I need to do to build unzip with debug info under Cygwin?

Also, I'd appreciate information about 

* the plausibility of my hypothesis. I suspect there is a problem in
  the new cygwin's malloc code: something that formerly did not return
  NULL now does, which is choking unzip. Does this sound reasonable?
  If so,

* where should I look for the underlying malloc code (cygwin1.dll?
  libc*?), and how should I build/debug that?

Feel free to forward, and to reply directly to me (as well as to the
list). Your assistance is appreciated, Tom Roche