Hi Daniel,

I've been moving house the last couple of weeks so have just got round 
to looking into this.

I originally thought this looked like a sizeof(int) discrepancy 
somewhere. I thought perhaps one component (pygame, SDL or _pycdgAux.c) 
had been built as 32-bit, or perhaps one of the underlying libraries is 
not 64-bit safe in some places.

Anyway, on looking into it further I see that the row_index value is 378 
(thanks for all the excellent debug info by the way). This is an invalid 
index into the array, as the CDG screen width and hence cdgSurfarray[][] 
is only max 300. For some reason this line in cdgTileBlockCommon() is 
reading an attempt to set pixel offset 378:

row_index = ((packd->data[3] & 0x3f) * 6);

CDG rips occasionally contain corrupted bytes, so I could well imagine 
that this could happen on the odd CDG file but it sounds like this 
probably happens on all files (please correct me if I'm wrong there).

Whether it's corrupted data or not, we really should be range-checking 
the row and column index here anyway. Could you try adding the following 
lines in cdgTileBlockCommon() please:

   // 2 lines of current code below
   column_index = ((packd->data[2] & 0x1f) * 12);
   row_index = ((packd->data[3] & 0x3f) * 6);

   // Enter the following 4 lines
   if (column_index > (CDG_FULL_HEIGHT - 12))
     column_index = (CDG_FULL_HEIGHT - 12);
   if (row_index > (CDG_FULL_WIDTH - 6))
     row_index = (CDG_FULL_WIDTH - 6);

If it's rogue data, then hopefully this will fix the seg fault. If it's 
not rogue data and somehow we're reading the CDG data out incorrectly, 
well we'll find that out. I hope you don't mind trying this out - I do 
actually have an AMD64 machine here but unfortunately I can't reproduce 
the problem. Perhaps if you could send the offending cdg+ogg files I 
could reproduce it.

Many thanks,
Kelvin.


> I've confirmed this with pykaraoke built from current CVS code. If anyone 
> needs it, I can provide the cdg+ogg files used below.
> 
> ----BEGIN (slightly edited) GDB SESSION----
> $ PYTHONPATH=lib/python2.4/site-packages gdb /usr/bin/python2.4
> GNU gdb 6.4.90-debian
> Copyright (C) 2006 Free Software Foundation, Inc.
> 
> (gdb) run bin/pycdg 02--Jolly_Holiday--karaoke.cdg
> Starting program: /usr/bin/python2.4 bin/pycdg 02--Jolly_Holiday--karaoke.cdg
> (no debugging symbols found)
> [Thread debugging using libthread_db enabled]
> [New Thread 47461752184672 (LWP 10233)]
> (no debugging symbols found)
> [New Thread 1082132832 (LWP 10236)]
> [New Thread 1090525536 (LWP 10237)]
> [Thread 1090525536 (zombie) exited]
> [New Thread 1090525536 (LWP 10239)]
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 47461752184672 (LWP 10233)]
> 0x00002b2a90ba6489 in __cdgTileBlockCommon (self=0x2aaaaae18010,
>     packd=0x7fff1e4879c0, xor=1) at _pycdgAux.c:783
> 783           self->__cdgSurfarray[row_index + j][column_index + i] = 
> self->__cdgColourTable[new_col];
> (gdb) p row_index
> $2 = 378
> (gdb) p j
> $3 = 0
> (gdb) p column_index
> $4 = 36
> (gdb) p i
> $5 = 0
> (gdb) p new_col
> $6 = 0
> (gdb) p self->__cdgColourTable[new_col]
> $7 = 11149824
> (gdb) p self->__cdgSurfarray[row_index + j][column_index + i]
> Cannot access memory at address 0x2aaaaae779fc
> (gdb) where
> #0  0x00002b2a90ba6489 in __cdgTileBlockCommon (self=0x2aaaaae18010,
>     packd=0x7fff1e4879c0, xor=1) at _pycdgAux.c:783
> #1  0x00002b2a90ba583f in __cdgPacketProcess (self=0x2aaaaae18010,
>     packd=0x7fff1e4879c0) at _pycdgAux.c:464
> #2  0x00002b2a90ba53bd in CdgPacketReader_DoPackets (self=0x2aaaaae18010,
>     args=0x2b2a8c69e050, kwds=0x0) at _pycdgAux.c:316
> #3  0x0000000000474517 in PyEval_EvalFrame ()
> #4  0x0000000000472c72 in PyEval_EvalFrame ()
> #5  0x0000000000472c72 in PyEval_EvalFrame ()
> #6  0x0000000000472c72 in PyEval_EvalFrame ()
> #7  0x0000000000472c72 in PyEval_EvalFrame ()
> #8  0x000000000047505c in PyEval_EvalCodeEx ()
> #9  0x0000000000475182 in PyEval_EvalCode ()
> #10 0x0000000000498da2 in PyRun_FileExFlags ()
> #11 0x0000000000498fa0 in PyRun_SimpleFileExFlags ()
> #12 0x0000000000410a5f in Py_Main ()
> #13 0x00002b2a8cbf04ca in __libc_start_main () from /lib/libc.so.6
> #14 0x000000000040ff3a in _start ()
> ----END GDB SESSION----
> 
> pykaraoke 0.5 handled this same file without a problem on an i386 system, 
> so some 64-bit snafu is likely at fault.
> 
> (Please Cc: any replies to me, as I am not subscribed to this list)
> 
> 
> --Daniel
> 
> 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Pykaraoke-discuss mailing list
Pykaraoke-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pykaraoke-discuss

Reply via email to