forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trying to solve a game crash (crt0_prx.c)

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
GlennNZ



Joined: 13 Jan 2007
Posts: 25

PostPosted: Tue Aug 05, 2008 9:30 pm    Post subject: Trying to solve a game crash (crt0_prx.c) Reply with quote

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:

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: 0x4600783C '<x.F' - c.lt.s     $fpr15, $fpr00
Resetting psplink


Using psp-addr2line I get
Code:

psp-addr2line -f -e Apollonia_PSP.elf 0x0000003C
_main
/home/glennm/psptoolchain/build/pspsdk/src/startup/crt0_prx.c: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:
_init();
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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Tue Aug 05, 2008 10:39 pm    Post subject: Reply with quote

Let's break it down.

Code:
Exception - FPU Exception (IUV)


You're getting an FPU exception.

Code:
Cause - 0x1000003C


The FPU exception is a division by zero.

Code:
EPC - 0x08859A24


You should be putting the EPC value into psp-addr2line, not the Cause value.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Aug 06, 2008 3:50 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Wed Aug 06, 2008 5:28 am    Post subject: Reply with quote

Oops missed that bit.

I saw the Apollonia_PSP.elf but totally missed the crt0_prx.c reference.
Back to top
View user's profile Send private message
GlennNZ



Joined: 13 Jan 2007
Posts: 25

PostPosted: Wed Aug 06, 2008 8:54 pm    Post subject: Reply with quote

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?t=10014&highlight=calc+epc+mod
I used psplink, made the game crash, then ran
Code:
calc $epc-$mod

This gave
Quote:
0x08859A3C
which is the same as the epc value.
I subsequently get the following with psp-addr2line.
Code:
psp-addr2line -f -e Apollonia_PSP.elf 0x08859A3C
??
??: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?t=9504&highlight=calc+epc+mod as a reference I tried and got the following in psp shell
Code:
host0:/> !psp-addr2line -e Apollonia_PSP.elf $?
/home/glennm/psptoolchain/build/pspsdk/src/startup/crt0_prx.c: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.
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Aug 07, 2008 3:08 am    Post subject: Reply with quote

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 ;)
Back to top
View user's profile Send private message
GlennNZ



Joined: 13 Jan 2007
Posts: 25

PostPosted: Thu Aug 07, 2008 5:57 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Aug 07, 2008 7:39 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu Aug 07, 2008 10:05 am    Post subject: Reply with quote

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

Was I mis-informed?
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Aug 07, 2008 10:15 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Aug 07, 2008 3:13 pm    Post subject: Reply with quote

Sigh, hence why I add (IUV) to tell you ;)
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Thu Aug 07, 2008 4:55 pm    Post subject: Reply with quote

TyRaNiD wrote:
Sigh, hence why I add (IUV) to tell you ;)


AH! I was wondering what that was for. :)
Back to top
View user's profile Send private message AIM Address
GlennNZ



Joined: 13 Jan 2007
Posts: 25

PostPosted: Wed Aug 13, 2008 7:01 am    Post subject: Reply with quote

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?t=9898&highlight=pspfpusetenable which says to include pspfpu.h

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

src/main.o: In function `main':
src/main.cpp:68: undefined reference to `pspfpu_set_enable'
collect2: ld returned 1 exit status
make: *** [Apollonia_PSP.elf] Error 1


What am I missing?
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Wed Aug 13, 2008 7:30 am    Post subject: Reply with quote

Adding -lpspfpu to your LIBS line in your makefile perhaps
Back to top
View user's profile Send private message
GlennNZ



Joined: 13 Jan 2007
Posts: 25

PostPosted: Wed Aug 13, 2008 8:30 pm    Post subject: Reply with quote

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

Cheers.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group