[fpc-pascal] Access Violation When SetLength(DynArray, Value)
Anthony Walter
sysrpl at gmail.com
Thu Sep 8 09:30:19 CEST 2022
Is there a known edge case issue connected to setting the length
of dynamic arrays?
I have a program that simulates a billiards game, and during the rerack
balls method of TPoolTable the number of pool balls on the table varies
based on the rerack option used. Currently, I am having a problem where an
exception is thrown if I try to SetLenth(Balls, 10) or greater than 10.
Values less than 10 work fine, but at 10 balls and above an exception is
thrown right at the SetLength call.
External: SIGSEGV
000000000041DCA4 eb12 jmp 0x41dcb8
<SYSTEM_$$_SYSGETMEM_VAR$QWORD$$POINTER+264>
000000000041DCA6 4c89f0 mov %r14,%rax
000000000041DCA9 488b5008 mov 0x8(%rax),%rdx
000000000041DCAD 488b4018 mov 0x18(%rax),%rax
000000000041DCB1 488982a8000000 mov %rax,0xa8(%rdx)
^ instruction pointer is at this line ^
I tried compiler both FPC 3.3.1 from trunk source and 3.2.2 from the
official Sourceforge binary. The same error occurs when building with both
compilers. My platform is x86_64 Linux.
For reference here is the type of Balls:
TVec2 = record
X, Y: Single;
end;
TPoolBall = record
Pos: TVec2;
Dir: TVec2;
Speed: Double;
Color: LongWord;
Touched: Boolean;
Sinking: Single;
SinkPocket: Integer;
SinkPos: TVec2;
Pocketed: Boolean;
Index: Integer;
end;
TPoolBalls = array of TPoolBall;
... later inside TPoolTable ...
Balls: TPoolBalls;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20220908/12deaa89/attachment-0001.htm>
More information about the fpc-pascal
mailing list