[Gambas-user] segfault with insanely large array of structures

Benoît Minisini gambas at ...1...
Mon Aug 12 18:58:42 CEST 2013


Le 12/08/2013 06:35, Kevin Fishburne a écrit :
> I know this code is horrible (it will be changed), but the following
> declarations and procedure raise a signal 11 and populate some of the
> array properties with non-zero values:
>
> ' Plan structures and array (server).
> Public Struct PlanBlockStructure ' Structure containing individual block
> data.
>    Created As Boolean      ' If block PWO has already been created.
>    Skin As Short           ' Block skin.
>    HeightCurrent As Single ' Current height in feet of block.
>    HeightTarget As Single  ' Target height in feet of block.
>    Grading As Boolean      ' If grading is required.
>    WorldX As Integer       ' Hard coordinates of block once construction
> has been initiated.
>    WorldY As Integer       ' Hard coordinates of block once construction
> has been initiated.
> End Struct
> Public Struct PlanStructure ' Structure containing individual plan data.
>    Block[300, 300] As Struct PlanBlockStructure
>    Stage As Byte       ' Current build stage (0 = design, 1 = clear and
> grade, 2 = wall construction, 3 = roofing construction, 4 = flooring
> construction, 5 = finished/maintenance).
>    CurrentX As Short   ' Current position in block array.
>    CurrentY As Short   ' Current position in block array.
>    GradeTo As Single   ' Elevation in feet to grade landscape to.
>    CenterX As Integer  ' Build site center coordinate.
>    CenterY As Integer  ' Build site center coordinate.
> End Struct
> Public Plan[2000] As Struct PlanStructure ' Architecutral plans.
>

Without a little project that reproduces the crash or at least an 
indication of where it crashes exactly, I can't do anything.

But I can tell you that if you use embedded arrays (the "xxx[xxx] As 
..." declarations), everything is allocated inside the object structure. 
It should work (independently of the available RAM, as Linux memory 
allocation is always successful, it crashes only when you want to access 
it). But 3,3 Gb being greater than 2^31, maybe there is bug somewhere, 
or it is too big to allocate that in one shot even to the kernel.

-- 
Benoît Minisini




More information about the User mailing list