How to debug exception

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

How to debug exception

Post by jockyw2001 »

I still have a nasty bug which prevents me from releasing my PMP VLC player. After playing a wifi streamed video for about 10-20 minutes I get this:

host0:/> Exception - Bus error (data)
Thread ID - 0x04CC4F6D
Th Name - Decode thread
Module ID - 0x039B9F33
Mod Name - PMP VLC Player 0.0.7
EPC - 0x08B1631C
Cause - 0x0000001C
BadVAddr - 0x0082828A
Status - 0x60008613
zr:0x00000000 at:0x08E40000 v0:0x00000001 v1:0x00000000
a0:0x00000000 a1:0x00000000 a2:0x00000000 a3:0x00000000
t0:0x000FF1B0 t1:0x00000080 t2:0x08BE9EA0 t3:0x08BEA290
t4:0x08BE9E98 t5:0x00001E04 t6:0x08901694 t7:0x00008600
s0:0x00000000 s1:0x091671B8 s2:0x00001096 s3:0x00000001
s4:0x091660D0 s5:0x00005DB8 s6:0x091660C0 s7:0x00000016
t8:0x00000001 t9:0x089A5CA8 k0:0x088E7F00 k1:0x00000000
gp:0x08BF2540 sp:0x088E7560 fp:0x09167040 ra:0x089A5694
reset
Resetting psplink

I can't do much with it. Does anyone know how to debug it? And does the error report give any clues? (apart from that the error occurs in the decode thread)
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

compile your code with -g (which will add debug info to the elf), then use psp-addr2line with the elf and the badvaddr and it will spit out the sourceline with the error. (bus error/data usually indicates some kind of problem with accessing misaligned data)
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

It's compiled with -g, but I only get

Code: Select all

$ psp-addr2line -e PMPVLC007.elf 0x0082828A
??:0
Am I missing something?

PS: JiniCho had a similar problem, see http://forums.ps2dev.org/viewtopic.php? ... =addr2line
Unfortunately I can't apply the solution given there
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Maybe the error occurs inside one of the libs (most likely libavcodec, since the thread in question is the Decode thread), but if this lib isn't compiled with the -g switch, line information for the code there won't be available.

Look out for misaligned data accesses like groepaz said, or also for unallocated mem accesses inside the decoding thread. I'm not sure what you changed from the original source, but unless you completely rewrote it, you should be able to find it by searching your additions.
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

also try 0x8082828A instead of 0x0082828A. and yes, if the crash is in a lib that has been compiled without -g, you wont get a lot of useful info :)

err that said, isnt 0x0082828A a kernel address ? :=P (so you are passing bad arguments to some kernel routine) try passing the address in RA to addr2line, it will give you a hint from where that bad call was done.

edit: bla, i'm confused. :=D

EPC - 0x08B1631C

thats the address you want to use. and badvaddr=0x0082828A pretty much shows the problem too, i bet you are trying to load a 32bit value from a non 32bit aligned address :=) (0x0082828A is not 32bit aligned)
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

groepaz wrote:EPC - 0x08B1631C

thats the address you want to use. and badvaddr=0x0082828A pretty much shows the problem too, i bet you are trying to load a 32bit value from a non 32bit aligned address :=) (0x0082828A is not 32bit aligned)
Yep this looks better :)

Code: Select all

$ psp-addr2line -f  -e PMPVLC007_JockyW.elf 0x08B1631C
memset
../../../../../../newlib/libc/machine/mips/memset.c:118
There are only 7 memset occurances in my code so it shouldn't be a too big problem to track the bug. That is assuming that the bug is not in one of the ffmpeg libs.

Thx a lot guys!
User avatar
groepaz
Posts: 305
Joined: Thu Sep 01, 2005 7:44 am
Contact:

Post by groepaz »

like i said, the value in RA should lead you to the line where memset was called (the line after that to be exact)
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

groepaz wrote:like i said, the value in RA should lead you to the line where memset was called (the line after that to be exact)
Bingo!

Code: Select all

$ psp-addr2line -f  -e PMPVLC007_JockyW.elf 0x089A5694
ogg_read_page
/home/KP/projects/PMPVLC007/libavformat/ogg2.c:293
It's the damn ogg container code which is part of ffmpeg libs.
Cool Groepaz, thanks a lot for your help!!!

Maybe I can now watch a full worldchampionship soccer game on my psp :)
looptrooper
Posts: 8
Joined: Sun Feb 12, 2006 12:20 pm

Post by looptrooper »

so you could trace the last bug and fixed it? no more waiting for the ultimative solution called PMP with VLC, you will release soon? can´t wait :)
User avatar
daurnimator
Posts: 38
Joined: Sun Dec 11, 2005 8:36 pm
Location: melbourne, australia

Post by daurnimator »

so... um... will you release it? :P
bada
Posts: 4
Joined: Thu Apr 27, 2006 9:18 pm

Post by bada »

i debug another way

Code: Select all

psp-objdump -S prog.elf >> prog.s
and find in prog.s by addres a mistake....
jockyw2001
Posts: 339
Joined: Thu Sep 29, 2005 4:19 pm

Post by jockyw2001 »

daurnimator wrote:so... um... will you release it? :P
Yes I will, in about an hour. Need to write a little manual first.
There are still plenty of issues, but they can wait until the next version.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

I'm already curious about your VLC version :)
Post Reply