[fpc-devel] 019605: Safety check for "const s: string" (similar to Range or Overflow checks)

Martin fpc at mfriebe.de
Fri Jun 24 00:41:48 CEST 2011

Another option would be to to the entire check, with a special memory 

Let the memory manager, add a byte to each request (probably 4 bytes for 
boundaries), and add a ref-counting like structure. This would only be 
used by "const param" => const param can use this to mark the block of 
memory (never mind if it is a string or elsewhat) as referenced => 
trying to free it, will cause an error

One could even add checksumming the memory...

Ok, probably to much...

On 23/06/2011 22:24, Martin wrote:
> On 23/06/2011 22:13, Florian Klämpfl wrote:
>> Am 23.06.2011 23:03, schrieb Martin:
>>> And what exactly does checkpointer check?
>> Check if the pointer points into a allocated memory block.
> Ok, that would actually work.
> even without  keep_released it could catch quite some
> It should check, that it points to the correct place inside an 
> allocated block (That is String^ := AllocAddr + SizeOf(StringLen) + 
> SizeOf(StrRefCnt)
> It could even check, that the refcount is not zero.
> If the memory has not yet been reallocated, that should fail, if the 
> string was released (assuming the last DecRefCnt, actually set's it to 
> zero, before releasing the memory) (Would not work with -gt => since 
> then all values are trashed)
> It would definitely be a good start.
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

More information about the fpc-devel mailing list