[fpc-pascal] Array [THandle] of pointer
Marc Weustink
marc at dommelstein.net
Wed Dec 24 00:23:31 CET 2008
Andrew Brunner wrote:
> Following Setup:
> Ubuntu 8.10 x64
> FPC 2.2.3 (latest and greatest)
> Lazarus (Latest and greatest)
>
> I'm seeing an anomaly with reading/writing to an Array[THandle] of Pointers.
>
> TMyStruct=record
> Index:integer;
> end;
> PMyStruct=^TMyStruct;
> TMyList = Array[THandle] of PMyStruct;
>
>
> If I declare a localized variable
> procedure Test();
> var
> MyTest:TMyList;
> hThread:THandle;
> begin
> hThread:=getCurrentThreadID;
> if (MyTest[hThread])=nil then begin // <---- CRASH HERE EXTERNAL SIGBUS
> end;
> end;
>
>
> This should not crash here. It should have been nil.
>
> Any work being done in this area or should I report another bug?
I'm surprised it crashes there. A THandle is IIRC a Cardinal on unix, so
by defining a variable MyTest:TMyList, you allocate 4GB *
SizeOf(TMyStruct) = 16GB on your stack. Usually a process doens't have
that much space and I wonder if you wanted this.
(You may want to look at the lcl Maps unit)
Marc
More information about the fpc-pascal
mailing list