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 

[SOLVED] Strange problems with exported function...

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



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Dec 23, 2009 4:12 am    Post subject: [SOLVED] Strange problems with exported function... Reply with quote

Hi, I've some problem with this function.
I'm using it by exporting from User prx to Vsh pbp,
it works for directory with no more than 2 subdirectories, otherwise it crash...
I can't undestrand why, probably something stupid, but maybe not....
I've thing that it could be a stack overflow but I've tryed to increase the calling thread stack and it still doesn't works...
Code:

SceUInt64 XioDirSize(char* Dir)
{
    return XioDirSizeFunct(Dir, 0);
}

SceUInt64 XioDirSizeFunct(char* Dir, SceUInt64 Size)
{
    int dl = sceIoDopen(Dir);
    if(dl < 0)
        return 0;
    SceIoDirent sid;
    char Fullname[256];
    memset(&sid, 0, sizeof (SceIoDirent));
    while(sceIoDread(dl, &sid) > 0)
    {
        if((strcmp(sid.d_name, ".") == 0) || (strcmp(sid.d_name, "..") == 0))
            continue;
       
        sprintf(Fullname, "%s/%s", Dir, sid.d_name);

        if(FIO_S_ISDIR(sid.d_stat.st_mode))
        {
            XioDirSizeFunct(Fullname, Size);
        }
        else
        {
            Size += sid.d_stat.st_size;
            memset(&sid, 0, sizeof (SceIoDirent));
        }
    }
    sceIoDclose(dl);
    return Size;
}

A question, exported functions use the calling thread stack?
_________________
Get Xplora!


Last edited by ne0h on Fri Dec 25, 2009 3:14 am; edited 2 times in total
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Dec 23, 2009 4:38 am    Post subject: Reply with quote

Two points
1. You calculation is wrong
Code:
        if(FIO_S_ISDIR(sid.d_stat.st_mode))
        {
            XioDirSizeFunct(Fullname, Size);
        }
should be
Code:
        if(FIO_S_ISDIR(sid.d_stat.st_mode))
        {
            Size = XioDirSizeFunct(Fullname, Size);
        }

2. I don't know if this matters but you didn't memset sid after getting "." or ".."
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Dec 23, 2009 4:41 am    Post subject: Reply with quote

Yes, I know ( for the 1st point ), I've tryed before to do it with a pointer, and I haven't added "Size = ...".
For the 2nd, I'll try but I don't think that can be that...
Sorry for my english,

ne0h
_________________
Get Xplora!
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Wed Dec 23, 2009 4:42 am    Post subject: Reply with quote

Still doesn't works...
_________________
Get Xplora!
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Wed Dec 23, 2009 5:21 am    Post subject: Reply with quote

try using psplink to to find the type and location of the error
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Dec 24, 2009 12:14 am    Post subject: Reply with quote

Can't use psplink, have no memory...
There's a way to install exception handler on 5.xx fws?
_________________
Get Xplora!
Back to top
View user's profile Send private message
psPea



Joined: 01 Sep 2007
Posts: 64

PostPosted: Thu Dec 24, 2009 8:47 am    Post subject: Reply with quote

Sakya posted one
Search and thou shalt findeth
_________________
Click ME!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Fri Dec 25, 2009 3:27 am    Post subject: Reply with quote

Resolved...
"Simple" stack overflow in cross-thread operation...
_________________
Get Xplora!
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