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 

Help with exception...[SOLVED]

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



Joined: 06 Sep 2007
Posts: 10

PostPosted: Sat Sep 22, 2007 12:11 pm    Post subject: Help with exception...[SOLVED] Reply with quote

Ok, running a program of mine using psplink sometimes it freezes up, and throws the following exception:

Code:

ms0:/PSP/GAME150/0test/>  ./eboot.pbp
Load/Start ms0:/PSP/GAME150/0test/eboot.pbp UID: 0x05045F07 Name: 0test
ms0:/PSP/GAME150/0test/>  Exception - FPU Exception (IUV)
Thread ID - 0x05019A19
Th Name   - user_main
Module ID - 0x05045F07
Mod Name  - 0test
EPC       - 0x089065D0
Cause     - 0x1000003C
BadVAddr  - 0x00008000
Status    - 0x20008613
zr:0x00000000 at:0x08940000 v0:0x00000000 v1:0x08A10000
a0:0x089E9F48 a1:0x09EFFD44 a2:0x089E9F3C a3:0x09EFFD44
t0:0x00000003 t1:0x08A11BF0 t2:0x08A11C40 t3:0x1AD08A39
t4:0x00000006 t5:0x401AD08A t6:0x180174A0 t7:0x00000000
s0:0x08A153C4 s1:0x00000000 s2:0x089E9F3C s3:0x00000024
s4:0x089F0000 s5:0x09EFFD44 s6:0x00000000 s7:0x00000000
t8:0x11DF46AA t9:0x00000000 k0:0x09EFFF00 k1:0x00000000
gp:0x


Using psp-addr2line i found out where the exception is occurring. zvar is just a typedef of float, and v3z is a typedef of ScePspFVector3. The weird thing is that i check both pointer inputs for null, but then in the middle of the function it is getting a bad pointer of some sort. Is the stack getting overflowed or corrupt or something? At first i thought fabs( ) was messing with me (that's why you see it commented out) but after taking that out i still get an exception. Exception location is pointed out below.

Also interesting to note that this function works fine most of the time...it runs hundreds of times each game loop, and only throws an error occasionally.

Code:

zvar quickDist2z( v3z * p1, v3z * p2 )
{
    if ( !p1 || !p2 )
    {
        null_ptr_count++;
        return 0;
    }
    zvar a = p2->x - p1->x;
    if ( a < 0 ) a = -a;
    zvar b = p2->y - p1->y;         //<------- exception here
    if ( b < 0 ) b = -b;
    return (b+a)/2.0f;
    //return ( fabs( p2->x - p1->x ) + fabs( p2->y - p1->y ) )/2;
}


Any thoughts or insights would be greatly welcome. I have tried running psp-gdb, but it doesn't seem to work. I am compiling with -g and i follow the instructions in the psplink manual but whenever i try to do psp-gdb ....etc target remote etc ... it times out.

Thanks!
_________________
woo


Last edited by arpaagent on Sun Sep 23, 2007 4:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sat Sep 22, 2007 1:38 pm    Post subject: Reply with quote

IUV indicates numeric underflow which is causing the exception.
Disable the underflow FPU exception.
Same problem as here, I think.
http://forums.ps2dev.org/viewtopic.php?t=8688

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
arpaagent



Joined: 06 Sep 2007
Posts: 10

PostPosted: Sun Sep 23, 2007 2:12 am    Post subject: Reply with quote

Thanks!

I disabled the FPU exceptions, and it no longer hangs, but now instead I get NaNs, and then my objects disappear. So I guess i'll have to track down the real source of the issue.
_________________
woo
Back to top
View user's profile Send private message
arpaagent



Joined: 06 Sep 2007
Posts: 10

PostPosted: Sun Sep 23, 2007 4:04 pm    Post subject: Reply with quote

Ok I figured out what the root of the problem was.

Well, I was using the ScePspFVector3, and i'm doing a lot of 2d stuff, so i'm not really worrying about the z-component of the vector a lot of the time. Unfortunately, this lead to me no initializing the z component in some cases, leaving it to be whatever the current state of the memory was whenever I grabbed one. This was ok while just doing x and y component operations, but occasionally i did use the z-component, and i guess sometimes the unitialized value that ended up in the z-component happened to be something that the FPU did not like. So, after making sure to init the z-component to zero in some of my functions, it seems to solve the problem.

Thanks for your initial help with this!
_________________
woo
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Sun Sep 23, 2007 6:58 pm    Post subject: Reply with quote

Thanks for posting back!
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
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