[futurebasic] Re: Array Overflow Crashes

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1998 : Group Archive : Group : All Groups

From: tatewake@... (TJ Grant)
Date:
>To my knowledge there is no storage protection in FB that would prevent
>this. So, you just end up overwriting the next n bytes of contiguous
>storage that is defined (if you have a subsequent DIM). Many operating
>systems force program check interrupts when a program writes over its own
>code just because these bugs are so insidiously hard to find.

Just as a step in debugging; you may want to try something like this:

dim array$(244)
replace:

array$(15) = "fuhred"
array$(1500) = "fuhred"
with:
local fn setArray(index&,thestr$)
 success% = _false'assume the worst
 long if index&>244 or index&<0
  success% = _false
 xelse
  array$(index&) = thestr$
  success% = _true
 end if
end fn = success%

and finally replace your assignment with either:
err% = setArray(15,"fuhred")
err% = setArray(1500,"fuhred")

Or I believe you can forget error checking all together without changing
the function
setArray(15,"fuhred")
setArray(1500,"fuhred")

I know, I'm pushing you into a sort of oop way of thinking :-)

But you may want to do it just for debugging; this will slow you down a
tad. (Not much, but a little)...



~ An FB revolution? I am there! ~

-- TJ Grant (tatewake@...)
Inspired Software. http://inspired.netstreet.net/
Macintosh, Dos, Windows, and BeOS software solutions.
Phone: 407-728-7563
....................................
.MacSloMo: 6502 emulation in FB!   .
.http://inspired.netstreet.net/POC/.
....................................