| View previous topic :: View next topic |
| Author |
Message |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Sat Dec 31, 2005 7:36 pm Post subject: fread weirdness with larger files |
|
|
Hello,
I'm attempting to port a game to PSP, and for some reason, the fread function has problems with large files. With a file on the memory stick which is around 2MB in size, the following call:
FILE* file = fopen("./myfile.dat", "rb");
int read = fread(buffer, 1, 65536, file);
returns 16384 instead of 65536. Subsequent calls return 0. Has anyone seen this problem before?
I'm not sure where to look for the source for fread, apologies if I'm doing something stupid...
Peter |
|
| Back to top |
|
 |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Sat Dec 31, 2005 8:31 pm Post subject: |
|
|
This may actually be a memory card corruption problem for me only - copying files onto the PSP via USB in a different order moves the problem to a different file.
On some files the PSP locks up completely. |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Jan 01, 2006 2:18 am Post subject: |
|
|
Have the PSP do a format on the memory stick and give it another go
I have had VERY strange problems with a memory stick that have been solved this way, due to corruption. |
|
| Back to top |
|
 |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Sun Jan 01, 2006 2:43 am Post subject: |
|
|
Thanks for the tip. I tried it out earlier (backing up my game saves, formatting the card, then restoring the saves) and it seems to have helped.
I still get the occasional problem though - e.g. files refusing to delete from the memory stick - I think my memory stick is knackered...
Thanks again for the advice. |
|
| Back to top |
|
 |
CyberBill
Joined: 26 Jul 2005 Posts: 86 Location: Redmond, WA
|
Posted: Sun Jan 01, 2006 2:53 am Post subject: |
|
|
The PSP is really... strange... in the way it handles file IO.
For instance, when doing any disk IO you can pass in a 'repeat' factor that says how many times to retry something, because it doesnt always work.
So, I say you call it until it does what you want. But thats just me :) |
|
| Back to top |
|
 |
av
Joined: 01 Jan 2006 Posts: 7
|
Posted: Tue Jan 03, 2006 9:25 pm Post subject: |
|
|
| I just spent 4 hours working through other file read related hang problems. You may want to try changing your Makefile to compile with -O1 instead of -O2. -O1 will do less optimization. However, -O2 seems to cause my app to hang the PSP if I change a line of code from time to time (I think gcc's optimizations are a little busted on the PSP). With -O1 everything seems to work as expected. |
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Wed Jan 04, 2006 12:12 am Post subject: |
|
|
| av wrote: | | I just spent 4 hours working through other file read related hang problems. You may want to try changing your Makefile to compile with -O1 instead of -O2. -O1 will do less optimization. However, -O2 seems to cause my app to hang the PSP if I change a line of code from time to time (I think gcc's optimizations are a little busted on the PSP). With -O1 everything seems to work as expected. |
Careful there - we don't see reports of anything breaking at -O2. Can you submit a valid repro for the hang?
A lot of time folks want to blame the compiler when they see weirdness caused by other bugs in their software. |
|
| Back to top |
|
 |
av
Joined: 01 Jan 2006 Posts: 7
|
Posted: Wed Jan 04, 2006 3:10 pm Post subject: |
|
|
| mrbrown wrote: | | A lot of time folks want to blame the compiler when they see weirdness caused by other bugs in their software. |
Unfortunately, while I can definitely repro it 100% of the time, it's in a code base that belongs to my company...and it's a pretty large code base with a full game level worth of data. So submitting a repro isn't possible.
The code has run fine for months in Windows for D3D. I've run BoundsChecker on it many, many times and while BoundsChecker isn't perfect, I've had no problems in the Windows build. The PSP build with -O1 runs without problems like the Windows build...the -O2 build hangs whenever I make completely safe changes like the following:
If I compile a for loop with a variable like:
for (int32 i=0; i<numLoops; i++)
That works fine. But when I change it to a constant:
for (int32 i=0; i<2; i++)
This hangs on the PSP right after the PSP loading screen fades away. Recompiling with -O1 causes it to work perfectly. Definitely looks like a compiler bug to me. This won't happen with all for loops, just certain ones that cause the compiler to crap the bed.
Thanks. |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Wed Jan 04, 2006 4:20 pm Post subject: |
|
|
| av wrote: | | it's a pretty large code base with a full game level worth of data. So submitting a repro isn't possible. |
If you can't give us a way to reproduce this "compiler bug", I'm afraid you're going to have no luck convincing any of us that it exists. |
|
| Back to top |
|
 |
groepaz

Joined: 01 Sep 2005 Posts: 305
|
|
| Back to top |
|
 |
|