Re: Sodipodi 0.34 on Amd64 crashes on startup

Lauris Kaplinski <[email protected]> Fri, 13 Feb 2004 20:30:19 +0200
Newsgroups gmane.comp.graphics.sodipodi
Message-ID <[email protected]>
Hello!

Thomas kirjutas R, 13.02.2004 kell 20:21:
> My first try:
> 
> $ gdb /usr/local/bin/sodipodi
> GNU gdb 5.3-26mdk (Mandrake Linux)
> Copyright 2002 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 "amd64-mandrake-linux-gnu"...
> (gdb) run
>         Keeping /usr/local/bin/sodipodi...
> Starting program: /usr/local/bin/sodipodi
> [New Thread 16384 (LWP 31140)]
>  
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 16384 (LWP 31140)]
> nr_svp_from_svl (svl=0x0, flat=0x0) at nr-svp.c:74
> 74              svp->length = nsegs;
> (gdb)
> 
> Does this give a clue as to where?

I do not know exactly where, but I know now why :-)

The bad piece of code is:

svp = malloc (sizeof (NRSVP) + (nsegs - 1) * sizeof (NRSVPSegment));

signed/unsigned mix. The bad thing happens, if nsegs = 0, i.e.
(nsegs - 1) = -1
As integers are 32 bit by default, 32-bit (-1) gets extended to
some very big number on 64-bit machine doing pointer arithmetic, 
resulting in try to allocate aroung 68GiB. It fails, of course, 
resulting NULL dereference in following line.

I'll try to prepare a patch and send it to list before tomorrow.

Best wishes,
Lauris Kaplinski





-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click