Welcome! Log In Create A New Profile

Advanced

Bug in libfat or in my code?

Posted by arasium 
Bug in libfat or in my code?
June 29, 2009 01:35PM
Hi,

recently i've encountered some errors with libfat and vectors. After some tests, it seems that errors come from libfat. Here is my simple test:

__io_wiisd.startup();
fatMountSimple("sd", &__io_wiisd);

DIR_ITER *dir = diropen("sd:/");

char directoryName[256];
struct stat directoryStat;
vector< string > vect;

while(!dirnext(dir, directoryName, &directoryStat))
{
  if ((directoryStat.st_mode & S_IFDIR))
  {
	  cout << directoryName << endl;
	  // I put a "test" instead of a directory name, to avoid any contact with libfat items
	  vect.push_back("test");
  }
}

dirclose(dir);
fatUnmount("sd");
__io_wiisd.shutdown();

// here, i've a crash (DSI Exception)
for(vector< string >::iterator ite = vect.begin(); ite != vect.end(); ite++)
  cout << *ite << endl;

Here is my previous post (if you want to know the history of my problem).

So, i don't find where is the bug if it's not in libfat. Is someone have a clue?



Edited 1 time(s). Last edit at 06/30/2009 02:10PM by arasium.
Re: Bug in libfat or in my code?
June 29, 2009 02:50PM
I don't think ithey are related to the crash but two things:

- the 2nd argument of dirnext should be able to store MAX_FILENAME_LENGTH (768) bytes according to the libfat code

- the mount/unmount functions automatically call the device "shutdown" & "startup" functions, there is no need for you to call these twice

About your crash, I don't know how you can deduct it's caused by libfat, what you are using (diropen/dirnext/dirclose) is commonly used without any trouble.
Most probably it's something with the STL vector implementation (push_back corrupting the memory ?)

Also what does the "Pause" function ?
Re: Bug in libfat or in my code?
June 29, 2009 05:14PM
Sorry, the Pause function just wait until the user push the A button. It's a simple loop with a if condition on the pad to break the loop.

It isn't the vector that create the bug. I've used the standard libraries (opendir, closedir, readdir) and the vector is ok with these functions. To add, the vector implementation comes from the stl, and i hope the stl doesn't contain this kind of bug.

I will try removing the startup and shutdown. And also, i will use a greater size for my buffer.



Edited 1 time(s). Last edit at 06/29/2009 05:15PM by arasium.
Re: Bug in libfat or in my code?
June 30, 2009 11:36AM
Hi,

is 'vector' here a typedef to vector<> or are you really using the STL's vector class this way?

regards
shagkur
Re: Bug in libfat or in my code?
June 30, 2009 02:10PM
Yes, it's an error in my copy past!!! Of course, i use the stl vector :
Sorry, only registered users may post in this forum.

Click here to login