[futurebasic] Re: [FB] Deallocation of a pointer not malloced ?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2007 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Fri, 23 Feb 2007 21:36:50 +1300
John McKernon wrote:

> I have a function that does:
>
> Long if gTextHndl&<>0
>   DEF DISPOSEH (gTextHndl&)
> End if
>
> Where gTextHndl& is a handle to some text, usually from the clipboard.
>
> gTextHndl& = FN NEWHANDLE(ScrapSz&)
>
> The DEF DISPOSEH line causes this entry to appear in the console.Log:
>
> FB_Temp(586,0xa000ed88) malloc: ***  Deallocation of a pointer not  
> malloced:
> 0xffffffff; This could be a double free(), or free() called with  
> the middle
> of an allocated block; Try setting environment variable MallocHelp  
> to see
> tools to help debug
>
> This only happens when gTextHndl& is non-zero, but not every time,  
> only
> after I've done some other very specific things that don't use  
> gTextHndl& at
> all.

Here's a way of producing that Console log message at will:

'--------------------------
dim as Handle @ h
h = fn NewHandle( 100 )
print "Handle's block pointer is 0x" hex$( [h] )
// simulate a memory-overwriting catastrophe
poke long h, -1
// [h] is now the invalid pointer 0xffffffff
print "Handle's block pointer is 0x" hex$( [h] )
def DisposeH( h )
stop
'--------------------------

Your gTextHndl& is perhaps the victim of a similar memory-trashing.

Robert P.