cbruner wrote:

The weird thing is that under the debugger it is able to run, although it stops at one point. When I try to just run it, it dies with the odd address error. Any ideas on how to understand where I went wrong?

The thing is that the debugger, simulators, and h/w devices will all react differently to memory corruption. For example, some of these will populate new chunks with NULLs, others will just leave whatever memory is there. And when you tromp on a pointer, your code will say "use whatever value is over there", and "over there" will be, basically, a random location. Reading or writing to a random location may cause a crash,.. or not... depending on where "over there" actually is.

<snip>
err = VFSFileOpen (volRefNum,Path, ro,&Handle);
<<<< Debugger stops on return of this call, as though an error occured in VFSFileOpen, with gray arrow. I'm guessing this is where the error is.

So, if you comment out that line of code you can run fine without errors? Crashing upon a simple return from a function almost always, in my experience, means that you have made some bad memory calls within that function. Focus on that function and disable parts of it until you find the culprit. Look for anywhere that you read or write to memory, and check that you validate the handles/pointers, and don't overrun any memory allocations. For instance, if you do something like:

char *st=MemPtrNew(20);
StrCopy(st,"Test");

you'll get a big problem on some (most?) systems because you didn't manually zero-out the memory first. Where in memory will it write "Test"? It will write it to the first NULL character position AFTER st, wherever that is. It is quite likely more than 20 characters beyond the location of st, so it will probably be overwriting something else, and that something might be important. To avoid this problem you do this BEFORE writing to the memory pointer:
st[0]=0;

This is going to take a little sleuthing on your part to fix. Take it a bit at a time, and track it down methodically.

Bob

--
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to