[Gambas-user] Segfault(11) when looping though an multidimensional array

Ian ian.roper at ...1974...
Wed Nov 5 11:56:54 CET 2014


This process was running fine and had been for quite some time.
after the daily update  on 3rd November , I now get the Segfault.


A seg fault appears when Az >0

(I have commented out all other elements that are not required.)

Declaration of the array is : Private LocationAry[51, 51, 5] As Integer

GridHeight has a value of 20,
GridWidth has a value of 20
===========================================
Private Sub DrawCurrentLocation()

   Dim Ax As Integer
   Dim Ay As Integer
   Dim Az As Integer
   Dim LastImage As Integer = -1
   Dim TmpScale As Integer = CInt(Scale)
   Dim P As Picture

   ' Draw.Begin(Dra_Main)
   ' Draw.Clear

   For Ax = 0 To GridWidth
     For Ay = 0 To GridHeight
       For Az = 0 To 4
         If LocationAry[Ax, Ay, Az] > 0 Then ' <----<<< fails here on 
the second loop if Ax > 0
           ' If LastImage <> LocationAry[Ax, Ay, Az] Then
           '  P = Img.GetPicture(LocationAry[Ax, Ay, Az])
           ' LastImage = LocationAry[Ax, Ay, Az]
           ' Endif
           ' Draw.Picture(P, Ax * TmpScale, Ay * Tmpscale, TmpScale, 
TmpScale)
         Endif
       Next
     Next
   Next
   ' Draw.End

End

====================================================
However !!! this still works without fault.

Private Sub ClearLocationArray()

   Dim Ax As Integer
   Dim Ay As Integer
   Dim Az As Integer

   For Ax = 0 To 50
     For Ay = 0 To 50
       For Az = 0 To 4
         LocationAry[Ax, Ay, Az] = 0
       Next
     Next
   Next

End
===================================================
edit: I set the clearLocationArray to a value of 1 instead of 0 and the 
segfault does not appear but I get an error saying "Null Object" but all 
of the array variables including the array
return a value during a mouse over in program halt ?
---------------------------------------------------------------------------------------------------------------
on daily updates from PPA gambas-team

[System]
Gambas=3.6.90
OperatingSystem=Linux
Kernel=3.13.0-24-generic
Architecture=x86_64
Distribution=Linux Mint 17 Qiana
Desktop=GNOME
Theme=QGtk
Language=en_AU.UTF-8
Memory=7858M
[Libraries]
Cairo=libcairo.so.2.11301.0
Curl=libcurl.so.4.3.0
DBus=libdbus-1.so.3.7.6
GStreamer=libgstreamer-0.10.so.0.30.0
GStreamer=libgstreamer-1.0.so.0.204.0
GTK+3=libgtk-3.so.0.1000.8
GTK+=libgtk-x11-2.0.so.0.2400.23
OpenGL=libGL.so.1.2.0
Poppler=libpoppler.so.44.0.0
Qt4=libQtCore.so.4.8.6
SDL=libSDL-1.2.so.0.11.4

cheers,
Ian Roper.




More information about the User mailing list