[GRASS-dev] [bug #4725] (grass) nviz crashed while volume visualisation

[ https://intevation.de/rt/webrt?serial_num=4725 ]

Hi,

"nviz volume=map3d" segfaults.. see bug report for spearfish example.

I've traced it back to incorrect mode in nviz/src/volume.c
slice_get_drawmode()

mode=1969841253 (or so)
when it should be like DM_GOURAUD=256 or DM_FLAT=512

actual segfault seems to happen after slice_get_drawmode()'s
return (TCL_ERROR);
???

called from scripts/panel_vol.tcl line ~450:
    set Nv_(ShadeStyle) [Nvol$curr slice get_drawmode]

I followed "mode" into lib/ogsf/GVL2.c GVL_slice_get_drawmode()
and then *gvl to gvl_get_vol() in lib/ogsf/gvl.c, but then I get lost.

uninit'd variable?

Hamish

-------------------------------------------- Managed by Request Tracker

Hi,
On Wednesday 28 June 2006 12:13, Harmish Bowman via RT wrote:

[ https://intevation.de/rt/webrt?serial_num=4725 ]

Hi,

"nviz volume=map3d" segfaults.. see bug report for spearfish example.

I've traced it back to incorrect mode in nviz/src/volume.c

slice_get_drawmode()

mode=1969841253 (or so)

when it should be like DM_GOURAUD=256 or DM_FLAT=512

actual segfault seems to happen after slice_get_drawmode()'s

return (TCL_ERROR);

???

called from scripts/panel_vol.tcl line ~450:

    set Nv_(ShadeStyle) [Nvol$curr slice get_drawmode]

I followed "mode" into lib/ogsf/GVL2.c GVL_slice_get_drawmode()

and then *gvl to gvl_get_vol() in lib/ogsf/gvl.c, but then I get lost.

uninit'd variable?
Hamish

Looks like.
If nviz is called with -q and a volume + isosurfaces are added -> nviz segfaults.
I have corrected the uninitialized variable:

cvs server: Diffing .
Index: gvl_calc.c

RCS file: /home/grass/grassrepository/grass6/lib/ogsf/gvl_calc.c,v
retrieving revision 1.3
diff -u -r1.3 gvl_calc.c
--- gvl_calc.c 9 Feb 2006 03:08:57 -0000 1.3
+++ gvl_calc.c 9 Jul 2006 13:48:54 -0000
@@ -444,7 +444,7 @@
{
     int x, y, z;
     int i, a, read;
- geovol_file *vf;
+ geovol_file *vf = NULL;
     geovol_isosurf *isosurf;

     data_buffer *dbuff;

and it works for me now. But i am not sure if this realy fixed the
problem.

But there is a second problem. If i start nviz with the option "volume"
and a valid volume map e.g.: nviz volume=vol
nviz receives a segmentation fault. This seems to be related to this line:

/home/grass/grassrepository/grass6/visualization/nviz/src/togl_flythrough.c:786
buf_vol = Tcl_GetVar(interp, "volume", TCL_GLOBAL_ONLY);

buf_vol is a NULL pointer and the program segfaults while the atoi(buf_*) calls later.

Something realy strange happens here if a volume map is provided. Maybe the parsing
functionality for volume maps is broken?

I have no clue where this functionality is defined, so i'm not able to fix this. :frowning:

Best
Soeren

Soeren Gebbert wrote:

> and then *gvl to gvl_get_vol() in lib/ogsf/gvl.c, but then I get lost.

> uninit'd variable?
> Hamish

Looks like.
If nviz is called with -q and a volume + isosurfaces are added -> nviz segfaults.
I have corrected the uninitialized variable:

cvs server: Diffing .
Index: gvl_calc.c

RCS file: /home/grass/grassrepository/grass6/lib/ogsf/gvl_calc.c,v
retrieving revision 1.3
diff -u -r1.3 gvl_calc.c
--- gvl_calc.c 9 Feb 2006 03:08:57 -0000 1.3
+++ gvl_calc.c 9 Jul 2006 13:48:54 -0000
@@ -444,7 +444,7 @@
{
     int x, y, z;
     int i, a, read;
- geovol_file *vf;
+ geovol_file *vf = NULL;
     geovol_isosurf *isosurf;

     data_buffer *dbuff;

and it works for me now. But i am not sure if this realy fixed the
problem.

I don't think so. In that function (gvl_isosurf_calc), "vf" is only
read if the variable "read" is non-zero. But the only places which set
"read" also set "vf":

--
Glynn Clements <glynn@gclements.plus.com>