[fpc-pascal] Access Violation When SetLength(DynArray, Value)

Peter B peter at pblackman.plus.com
Thu Sep 8 10:44:37 CEST 2022


I suggest trying without optimisations and/or using cmem, to see if that changes the outcome.

Also, if the array is corrupted prior to the setlength, then iterating the array with a trivial
   with... Writeln(Color)
or whatever, should trigger an exception.

That could then be used at various parts of the program to identify the point of corruption,
which might seem unrelated to array in question if the heap is getting messed up somehow.


Cheers,
Peter

P.S.

I had a strange (possible) heap corruption issue with a large program a year ago that broke stringlists.
I never found the cause, and after many minor code changes, the problem just dissappeared.


More information about the fpc-pascal mailing list