[GRASS-dev] nviz raster volume segfault

Bug #4725 http://intevation.de/rt/webrt?serial_num=4725

Hi,

trying to track down the latest incarnation of the NVIZ Volume segfault.

# instructions how to make "vox50" in bug report #4725,
# prob any r3 map will do
G63> g.region rast3d=vox50
G63> nviz vol=vox50

(optional) Adjust height slider to 100.0. (type it in)

[Viz -> Volumes]
[Add] new isosurface
Segmentation fault

Happens about 70% of the time, if works once, it will continue to work
for that NVIZ session.

The segfault happens in nviz/scripts/attIsosurfPopup.tcl line ~132.
    focus $w
    if {$mode} {grab $w}

    # tkspecial_wait window $w
-> tkwait window $w

    if {$DEBUG} {puts "Exiting from attIsoPopup"}

I assume that means it happens sometime when the $w window is open, not
in the tkwait call itself (tkwait just ends the main input loop).

gdb shows it happens in nviz/src/togl.c line 1947:
   /* don't share display lists */
   togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);

I notice that when the window does pop up, and you click custom value,
the cursor is not in the text entry box, and clicking on the text entry
box doesn't help. I need to set the focus to another window, then back
to the text entry window, then click in the box to get a cursor.

gdb session follows.

?,
Hamish

G63> gdb $GISBASE/etc/nviz2.2/nviz
(gdb) run -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script vol=vox50
Starting program: /usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/etc/nviz2.2/nviz -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script vol=vox50
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 18519)]

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 16384 (LWP 18519)]
0x419dbae0 in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so

#### Note this SEGFPE is at at startup, not when clicking "Add".
#### Empty grey NVIZ window (200x200) and black "Please wait..." windows are open.

(gdb) bt
#0 0x419dbae0 in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#1 0x419db67b in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#2 0x419db7bf in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#3 0x419492b2 in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#4 0x419492d9 in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#5 0x418c6c5a in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#6 0x418c8d7c in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#7 0x418c91e8 in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#8 0x419e01bc in __driUtilCreateScreen () from /usr/X11R6/lib/modules/dri/r200_dri.so
#9 0x418b235d in __driUtilUpdateDrawableInfo () from /usr/X11R6/lib/modules/dri/r200_dri.so
#10 0x40828195 in _glthread_SetTSD () from /usr/X11R6/lib/libGL.so.1
#11 0x408282ec in glXCreateContext () from /usr/X11R6/lib/libGL.so.1
#12 0x08063e7b in Togl_CreateWindow (tkwin=0x8126008, parent=48234524, instanceData=0x8126120)
    at togl.c:1947
#13 0x4063df88 in Tk_MakeWindowExist () from /usr/lib/libtk8.3.so.1
#14 0x080635ed in Togl_Cmd (clientData=0x808d9b8, interp=0x807a540, argc=8, argv=0xbfffea20)
    at togl.c:1571
#15 0x406f97ab in TclInvokeStringCommand () from /usr/lib/libtcl8.3.so.1
#16 0x407140c8 in TclExecuteByteCode () from /usr/lib/libtcl8.3.so.1
#17 0x406fa07f in Tcl_EvalObjEx () from /usr/lib/libtcl8.3.so.1
#18 0x40737f4c in TclObjInterpProc () from /usr/lib/libtcl8.3.so.1
#19 0x4073129c in TclExpandTokenArray () from /usr/lib/libtcl8.3.so.1
#20 0x40731b3d in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
#21 0x40728a0e in Tcl_EvalFile () from /usr/lib/libtcl8.3.so.1
#22 0x40632774 in Tk_MainEx () from /usr/lib/libtk8.3.so.1
#23 0x080622e0 in main (argc=4, argv=0xbffff624) at nvizMain.c:62

(gdb) bt full
[...]
#12 0x08063e7b in Togl_CreateWindow (tkwin=0x8126008, parent=48234524, instanceData=0x8126120)
    at togl.c:1947
        attempt = 0
        togl = (Togl *) 0x8126120
        visinfo = (XVisualInfo *) 0x8127d40
        dpy = (Display *) 0x8086a48
        cmap = 0
        scrnum = 1073835168
        window = 1075391240
        directCtx = 1
        attrib_list = {1, 4, 8, 1, 9, 1, 10, 1, 12, 1, 5, 0 <repeats 353 times>, 1084246465,
  0, 0, 1093267355, 0, 1085040226, 1085042247, -1073748628, 1084157883, -1073748600,
  1085040226, 6, 0, 0, 0, 0, 0, -1073748648, 1084150807, 0 <repeats 47 times>, 544407552, 0,
  4, -4, 0 <repeats 14 times>, -1073749720, 0, 2, -1073748388, -1073748648, 0, 1085040217,
  15, -1, 0 <repeats 22 times>, 1085040225, 1085040232, 0 <repeats 38 times>, 1084246465, 0,
  0, 0, 0, 1081434067, -1073748030, -1073748008, 1084157883, -1073747980, 1081434067, 0, 0,
  0, 0, 0, 0, -1073748028, 1084150807, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1084246465, 0, 0, 0, 0,
  1081434067, -1073747917, -1073747896, 1084157883, -1073747868, 1081434067, 0, 0, 0, 0, 0,
  0, -1073747916, 1084150807, 0 <repeats 19 times>, 543424512, 0 <repeats 12 times>, 10, 10,
  135417804, 0, 0, -1073749100, 0, 1, -1073747768, -1073748028, 0, 1081434065, 6, -1, 0,
  543424512, 0 <repeats 12 times>, 10, 8, 135397492, 0, 0, -1073748988, 0, 1, -1073747656,
  1081434067, 0...}
        attrib_count = 12
        dummy = 77
        swa = {background_pixmap = 0, background_pixel = 0, border_pixmap = 0,
  border_pixel = 0, bit_gravity = 0, win_gravity = 0, backing_store = 0, backing_planes = 0,
  backing_pixel = 0, save_under = 0, event_mask = 0, do_not_propagate_mask = 0,
  override_redirect = 0, colormap = 0, cursor = 0}
        ci_depths = {8, 4, 2, 1, 12, 16, 8, 4, 2, 1, 12, 16}
        dbl_flags = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}
#13 0x4063df88 in Tk_MakeWindowExist () from /usr/lib/libtk8.3.so.1
No symbol table info available.
#14 0x080635ed in Togl_Cmd (clientData=0x808d9b8, interp=0x807a540, argc=8, argv=0xbfffea20)
    at togl.c:1571
        name = 0x811ead0 ".middle.draw.canvas"
        mainwin = 0x808d9b8
        tkwin = 0x8126008
        togl = (Togl *) 0x8126120
[...]

#### not the same gdb session:
(gdb) frame 12
#12 0x08063e87 in Togl_CreateWindow (tkwin=0x8125f50, parent=48234524, instanceData=0x8126068)
    at togl.c:1947
1947 togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);

(gdb) list
1942 shareCtx = None;
1943 togl->GlCtx =
1944 glXCreateContext(dpy, visinfo, shareCtx, directCtx);
1945 } else {
1946 /* don't share display lists */
1947 togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);
1948 }
1949
1950 if (togl->GlCtx == NULL) {
1951 Tcl_SetResult(togl->Interp,

I notice during make:

togl.c: In function `Togl_Configure':
togl.c:1240: warning: passing arg 5 of `Tk_ConfigureWidget' from incompatible pointer type
togl.c: In function `Togl_Widget':
togl.c:1339: warning: passing arg 4 of `Togl_Configure' from incompatible pointer type
togl.c: In function `Togl_Cmd':
togl.c:1431: warning: passing arg 3 of `Tk_CreateWindowFromPath' discards qualifiers from pointer target type
togl.c:1551: warning: passing arg 4 of `Togl_Configure' from incompatible pointer type

Hamish wrote:

Bug #4725 http://intevation.de/rt/webrt?serial_num=4725

vox50 3d raster is here:
  http://grass.gdf-hannover.de/wiki/Help_with_3D#Examples

But more tests show that this happens in the same place on startup even
with the no-opt "-q" quick flag.

G63> gdb $GISBASE/etc/nviz2.2/nviz
(gdb) run -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script -q

Starting program: /usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/etc/nviz2.2/nviz -f $GISBASE/etc/nviz2.2/scripts/nviz2.2_script -q
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 18821)]

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 16384 (LWP 18821)]

(gdb) frame 12
#12 0x08063e7b in Togl_CreateWindow (tkwin=0x8121690, parent=44040220, instanceData=0x81217a8)
    at togl.c:1947
1947 togl->GlCtx = glXCreateContext(dpy, visinfo, None, directCtx);

So not volume= specific!

Hamish