> I think that the problem actually lies elsewhere.
>
> First, if the stack indeed overflowed, then the Palm
> OS Emulator would have reported it. That's one of
>the standard checks it makes any time A7 (the stack
> pointer) is adjusted.
>
> Second, even if a stack overflow occurred and the
>Palm OS Emulator didn't catch or report it, I don't
>think that a stack overflow would lead to the actual
> reported problem. If the local pointer actually
> pointed to a global variable, then that pointer
>would still be outside the reported stack range, and
> the Emulator would not report it as an error.
>
> I think it far more likely that the local pointer
>variable actually points to a local variable of a
>function that was called and had since returned.
E.g:
>
> char* MyGetBuffer()
> {
> char myBuffer[0x400];
> return myBuffer;
> }
>
> If the result of MyGetBuffer is stored in the OP's
>local pointer variable and then used to access the
>buffer, you'd get the error message reported. Notice
>how the memory location reported in the error message
>is 0x510 bytes below the stack pointer, which might
>be explained by a conveniently-sized 1K buffer in
>there somewhere.
>
>The OP has since reported that he's fixed the
>problem, but I don't understand his explanation.
>
>-- Keith Rollin
>-- Palm OS Developer Tools engineer
Thanks for the reply. I'm the OP and the problem
wasn't fixed in my first reply, but it is now. You
describe what I'm doing almost exactly. The local
pointer is assigned from a function that was called on
a global variable/object, in order to change the
contents of that global object.
The problem was that the global object wasn't properly
set up, so the pointer returned was indeed pointing to
unused area in the stack and not in the heap, where I
thought it was.
I thought the error was telling me that a local
pointer couldn't write to a location in the heap,
which made me wonder how you could ever make lasting
changes, i.e. changes to global data from within a
local function.
So I've learned my little lesson for the day. ;-)
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/