Trying to solve a game crash (crt0_prx.c)

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

Moderators: cheriff, TyRaNiD

Post Reply
GlennNZ
Posts: 25
Joined: Sat Jan 13, 2007 1:13 pm

Trying to solve a game crash (crt0_prx.c)

Post by GlennNZ »

I'm trying to find out why my program has suddenly started to crash on me. As of yet I can't figure out if it is my fault or not but it's happened since implementing vertex arrays using PSPGL. However, it also crashes when I disable all vertex arrays so I'm not sure what it could be. What's worse, as it seems to do it at random. Sometimes I can play for a few minutes, other times it crashes after a few seconds so I have no idea what is triggering it.

What I get with PSP Link is:

Code: Select all

Exception - FPU Exception (IUV)
Thread ID - 0x04A7CD05
Th Name   - user_main
Module ID - 0x00D97479
EPC       - 0x08859A24
Cause     - 0x1000003C
BadVAddr  - 0x35400244
Status    - 0x60088613
zr:0x00000000 at:0x2008FF00 v0:0x40000000 v1:0x1E000000
a0:0x08D359E8 a1:0x1E000001 a2:0x00000001 a3:0x40000000
t0:0x08D35970 t1:0x08D35CEC t2:0x08D35988 t3:0x00000000
t4:0x089CB860 t5:0x00003E0C t6:0x0885F6EC t7:0x20088600
s0:0x09FBFD68 s1:0x09FBFD64 s2:0x089D0000 s3:0x09FBFEE0
s4:0x00000019 s5:0x00000013 s6:0x09FBFD6C s7:0x092A8D64
t8:0x00000004 t9:0x00000000 k0:0x09FBFF00 k1:0x00000000
gp:0x089DE690 sp:0x09FBFD40 fp:0x092A8D50 ra:0x088214C8
0x08859A24&#58; 0x4600783C '<x.F' - c.lt.s     $fpr15, $fpr00
Resetting psplink
Using psp-addr2line I get

Code: Select all

psp-addr2line -f -e Apollonia_PSP.elf 0x0000003C
_main
/home/glennm/psptoolchain/build/pspsdk/src/startup/crt0_prx.c&#58;67
I'm of the understanding that I have to change 0x1000003C to 0x0000003C or else I don't get anything meaningful.

Digging into crt0_prx.c shows that line 67 has

Code: Select all

_init&#40;&#41;;
which is unfortunately somewhere I don't know where to go next.

Does anyone have any experience with this issue? And is there any other information that I should be able to get from the crash dump? I get a lot of
??
??:0

I hope this isn't a difficult question, but I'm not holding my breath.

Cheers.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Let's break it down.

Code: Select all

Exception - FPU Exception &#40;IUV&#41;
You're getting an FPU exception.

Code: Select all

Cause - 0x1000003C
The FPU exception is a division by zero.

Code: Select all

EPC - 0x08859A24
You should be putting the EPC value into psp-addr2line, not the Cause value.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

In fact with a PRX you need to put in the relative address, depending on the version of psplink you have you might be able to do 'calc $epc-$mod' to get the address or you have to do it manually.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Oops missed that bit.

I saw the Apollonia_PSP.elf but totally missed the crt0_prx.c reference.
GlennNZ
Posts: 25
Joined: Sat Jan 13, 2007 1:13 pm

Post by GlennNZ »

I'm don't think I'm using the tools properly.

I've read up on some previous posts and going by http://forums.ps2dev.org/viewtopic.php? ... lc+epc+mod
I used psplink, made the game crash, then ran

Code: Select all

calc $epc-$mod
This gave
0x08859A3C
which is the same as the epc value.
I subsequently get the following with psp-addr2line.

Code: Select all

psp-addr2line -f -e Apollonia_PSP.elf 0x08859A3C
??
??&#58;0
A comment was made to try calc $mod-$epc instead. This gives 0xF77A65C4 which is turn provides ??

Using http://forums.ps2dev.org/viewtopic.php? ... lc+epc+mod as a reference I tried and got the following in psp shell

Code: Select all

host0&#58;/> !psp-addr2line -e Apollonia_PSP.elf $?
/home/glennm/psptoolchain/build/pspsdk/src/startup/crt0_prx.c&#58;61
which, funny enough, takes me back to where I started.

I've noticed that I crash a lot in PSPLink but haven't crashed yet when I copy and use the actual eboot file.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

I guess Sony might finally have made it so fpu exceptions are ignored, the PSP fpu sucks badly in certain situations ;) You could just disable the exceptions with pspfpu_set_enable(0); at the start of your code ;)
GlennNZ
Posts: 25
Joined: Sat Jan 13, 2007 1:13 pm

Post by GlennNZ »

Insert_witty_name said that an FPU exception is a divide by zero issue. Is that the case or is it from uninitialised floating point numbers? I ask because I know the fp means floating point but I don't know what the 'u' stands for.

Is there a way for me to find out if it is happening in my code or in one of the libraries? Obviously I'd rather not have that situation occuring, but considering that the Linux build appears fine, it might be out of my control; unless Linux is guarding me against my dodgey code.

I have PSPLink v3.0 OE, according to the PSP's menu (if that info is of any use).

I'll try pspfpu_set_enable(0)
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

It isn't divide by zero, it is probably uninitialised float as you say. The IUV indicates the "error" flags set. See http://forums.ps2dev.org/viewtopic.php?t=8688 which was exactly the same type of error.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

I was informed previously that Cause - 0x1000003C is a division by zero.

Was I mis-informed?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

0x1000003C
--------------
1 = coprocessor 1 (FPU)
3C = ExcCode of 0xf = FPE (Floating Point Exception)

I don't think the dump you posted above shows the FP status register to see what kind of FPE it is.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Sigh, hence why I add (IUV) to tell you ;)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

TyRaNiD wrote:Sigh, hence why I add (IUV) to tell you ;)
AH! I was wondering what that was for. :)
GlennNZ
Posts: 25
Joined: Sat Jan 13, 2007 1:13 pm

Post by GlennNZ »

How do I go about getting pspfpu_set_enable(0) to work. The only other post that mentions this method is http://forums.ps2dev.org/viewtopic.php? ... usetenable which says to include pspfpu.h

I've done so and put pspfpu_set_enable(0); in my main() method. However, I get

Code: Select all

src/main.o&#58; In function `main'&#58;
src/main.cpp&#58;68&#58; undefined reference to `pspfpu_set_enable'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;Apollonia_PSP.elf&#93; Error 1
What am I missing?
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Adding -lpspfpu to your LIBS line in your makefile perhaps
GlennNZ
Posts: 25
Joined: Sat Jan 13, 2007 1:13 pm

Post by GlennNZ »

Whoops. I thought I'd already tried that. I must have missed out the l again.

Cheers.
Post Reply