[SOLVED] Strange problems with exported function...

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

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

[SOLVED] Strange problems with exported function...

Post by ne0h »

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: Select all

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

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

        if&#40;FIO_S_ISDIR&#40;sid.d_stat.st_mode&#41;&#41;
        &#123;
            XioDirSizeFunct&#40;Fullname, Size&#41;;
        &#125;
        else
        &#123;
            Size += sid.d_stat.st_size;
            memset&#40;&sid, 0, sizeof &#40;SceIoDirent&#41;&#41;;
        &#125;
    &#125;
    sceIoDclose&#40;dl&#41;;
    return Size;
&#125;
A question, exported functions use the calling thread stack?
Last edited by ne0h on Fri Dec 25, 2009 3:14 am, edited 2 times in total.
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

Two points
1. You calculation is wrong

Code: Select all

        if&#40;FIO_S_ISDIR&#40;sid.d_stat.st_mode&#41;&#41; 
        &#123; 
            XioDirSizeFunct&#40;Fullname, Size&#41;; 
        &#125; 
should be

Code: Select all

        if&#40;FIO_S_ISDIR&#40;sid.d_stat.st_mode&#41;&#41; 
        &#123; 
            Size = XioDirSizeFunct&#40;Fullname, Size&#41;; 
        &#125; 
2. I don't know if this matters but you didn't memset sid after getting "." or ".."
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

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
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Still doesn't works...
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

try using psplink to to find the type and location of the error
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Can't use psplink, have no memory...
There's a way to install exception handler on 5.xx fws?
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

Sakya posted one
Search and thou shalt findeth
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Resolved...
"Simple" stack overflow in cross-thread operation...
Post Reply