[GRASS-dev] v.digit segfault with tcltk 8.3 -- solution?

Hi,

WRT the "new" v.digit segfaulting on startup (Tcl/Tk 8.3; Debian/Sarge;
i686), I have traced it to vector/v.digit/driver.c in the get_window()
fn:

Tcl_Eval(Toolbox, "list 0 [winfo height .screen.canvas] 0 [winfo width .screen.canvas]");

even this breaks it:
    Tcl_Eval(Toolbox, "list [winfo height .screen.canvas]");
or just
    Tcl_Eval(Toolbox, "list [expr 1+1]");
or
    Tcl_Eval(Toolbox, "concat [expr 1]");

while this works:
    Tcl_Eval(Toolbox, "winfo height .screen.canvas");

note that a few lines later it calls this, without error:
    Tcl_Eval(Toolbox, "list 0 [.screen.canvas cget -height] 0 [.screen.canvas cget -width]");

no idea why nesting [commands] matters, but without it works & the
attached patch gets v.digit working again for tcltk 8.3.

ok for CVS?

Hamish

(attachments)

vdig_driver8.3.diff (972 Bytes)

Hamish wrote:

WRT the "new" v.digit segfaulting on startup (Tcl/Tk 8.3; Debian/Sarge;
i686), I have traced it to vector/v.digit/driver.c in the get_window()
fn:

Tcl_Eval(Toolbox, "list 0 [winfo height .screen.canvas] 0 [winfo width .screen.canvas]");

even this breaks it:
    Tcl_Eval(Toolbox, "list [winfo height .screen.canvas]");
or just
    Tcl_Eval(Toolbox, "list [expr 1+1]");
or
    Tcl_Eval(Toolbox, "concat [expr 1]");

while this works:
    Tcl_Eval(Toolbox, "winfo height .screen.canvas");

note that a few lines later it calls this, without error:
    Tcl_Eval(Toolbox, "list 0 [.screen.canvas cget -height] 0 [.screen.canvas cget -width]");

no idea why nesting [commands] matters, but without it works

The only thing which I can think of is that the Tcl interpreter is
corrupt.

Can you provide a backtrace? The fact that it's happening in
get_window() is less interesting than knowing how far through the
initialisation stage it has got.

& the
attached patch gets v.digit working again for tcltk 8.3.

ok for CVS?

No. The patch is a workaround; it doesn't *fix* anything.

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

On Thu, May 10, 2007 at 10:00:55PM +1200, Hamish wrote:

WRT the "new" v.digit segfaulting on startup (Tcl/Tk 8.3; Debian/Sarge;
i686), I have traced it to vector/v.digit/driver.c in the get_window()
fn:

Why using tcl 8.3 instead of 8.4?

--
Francesco P. Lovergine

Francesco Paolo Lovergine wrote:

> WRT the "new" v.digit segfaulting on startup (Tcl/Tk 8.3;
> Debian/Sarge; i686), I have traced it to vector/v.digit/driver.c in
> the get_window() fn:

Why using tcl 8.3 instead of 8.4?

to catch any 8.4isms & thus keep GRASS compatible with 8.3 for people
on older systems that they might not easily be able/allowed to upgrade.

Hamish

Hamish wrote:
> WRT the "new" v.digit segfaulting on startup (Tcl/Tk 8.3;
> Debian/Sarge; i686), I have traced it to vector/v.digit/driver.c in
> the get_window() fn:
>
> Tcl_Eval(Toolbox, "list 0 [winfo height .screen.canvas] 0 [winfo
> width .screen.canvas]");

..

> while this works:
> Tcl_Eval(Toolbox, "winfo height .screen.canvas");
>
> note that a few lines later it calls this, without error:
> Tcl_Eval(Toolbox, "list 0 [.screen.canvas cget -height] 0
> [.screen.canvas cget -width]");
>
> no idea why nesting [commands] matters, but without it works

Glynn:

The only thing which I can think of is that the Tcl interpreter is
corrupt.

Can you provide a backtrace? The fact that it's happening in
get_window() is less interesting than knowing how far through the
initialisation stage it has got.

Debian does not have unstripped debug versions of the Tcl/Tk pacakges
to play with.

G63> gdb `which v.digit`
...
(gdb) run -n test123
Starting program: /usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/bin/v.digit -n test123
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 22890)]

** (empty canvas and toolbox windows open at expected size) **

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 22890)]
0x406e5a02 in Tcl_ParseCommand () from /usr/lib/libtcl8.3.so.1

(gdb) where
#0 0x406e5a02 in Tcl_ParseCommand () from /usr/lib/libtcl8.3.so.1
#1 0x406e6a77 in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
#2 0x406e6967 in Tcl_EvalTokens () from /usr/lib/libtcl8.3.so.1
#3 0x406e6ad8 in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
#4 0x406e6ead in Tcl_Eval () from /usr/lib/libtcl8.3.so.1
#5 0x080507c3 in get_window (t=0xbfffdddc, b=0xbfffddd8, l=0xbfffddd4, r=0xbfffddd0) at driver.c:58
#6 0x080508fd in setup () at driver.c:81
#7 0x08050a08 in driver_open () at driver.c:109
#8 0x0804fa35 in tool_centre () at centre.c:51
#9 0x0804e9e7 in c_tool_centre (cdata=0x0, interp=0x80689e8, argc=1, argv=0xbfffdf40) at c_face.c:159
#10 0x406ae7ab in TclInvokeStringCommand () from /usr/lib/libtcl8.3.so.1
#11 0x406e629c in TclExpandTokenArray () from /usr/lib/libtcl8.3.so.1
#12 0x406e6b3d in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
#13 0x406dda0e in Tcl_EvalFile () from /usr/lib/libtcl8.3.so.1
#14 0x4060a774 in Tk_MainEx () from /usr/lib/libtk8.3.so.1
#15 0x080551ee in main (argc=3, argv=0xbffff6b4) at main.c:171

(gdb) bt full
#0 0x406e5a02 in Tcl_ParseCommand () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#1 0x406e6a77 in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#2 0x406e6967 in Tcl_EvalTokens () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#3 0x406e6ad8 in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#4 0x406e6ead in Tcl_Eval () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#5 0x080507c3 in get_window (t=0xbfffdddc, b=0xbfffddd8, l=0xbfffddd4, r=0xbfffddd0) at driver.c:58
No locals.
#6 0x080508fd in setup () at driver.c:81
        region = {format = 1, compressed = 1081160844, rows = -1073750520, rows3 = 1080762859, cols = 136024448,
  cols3 = -1073750208, depths = -1073750344, proj = 134555899, zone = 134646248, ew_res = -1.9917528645776512,
  ew_res3 = 1.3045924948466768e-269, ns_res = -1.9918747250277136, ns_res3 = 5.3338737180735451e-270,
  tb_res = 1.304592313105002e-269, north = 5.3328916924585565e-270, south = -1.9917984008789062,
  east = 5.3328916923058305e-270, west = 2.1892007977165914e-314, top = 5.4188659499049665e+247,
  bottom = 4.5736388515644127e-72}
        t = 0
        b = 1
        l = 135866056
        r = 136024448
#7 0x08050a08 in driver_open () at driver.c:109
        n = 275.28436279248785
        s = 5.1156834854061882e-270
        e = 356.56707763623717
        w = -1.9920043945312502
#8 0x0804fa35 in tool_centre () at centre.c:51
No locals.
#9 0x0804e9e7 in c_tool_centre (cdata=0x0, interp=0x80689e8, argc=1, argv=0xbfffdf40) at c_face.c:159
No locals.
#10 0x406ae7ab in TclInvokeStringCommand () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#11 0x406e629c in TclExpandTokenArray () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#12 0x406e6b3d in Tcl_EvalEx () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#13 0x406dda0e in Tcl_EvalFile () from /usr/lib/libtcl8.3.so.1
No symbol table info available.
#14 0x4060a774 in Tk_MainEx () from /usr/lib/libtk8.3.so.1
No symbol table info available.
#15 0x080551ee in main (argc=3, argv=0xbffff6b4) at main.c:171
        i = 0
        module = (struct GModule *) 0x40075cd0
        map_opt = (struct Option *) 0x40075c80
        bgcmd_opt = (struct Option *) 0x80623d0
        new_f = (struct Flag *) 0x40075c58
        mapset = 0x80624d0 "user3"
        tokens = (char **) 0x80624d0
        fake_argv = {0xbffff809 "/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/bin/v.digit", 0x805be84 "-f",
  0xbfffe620 "/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/etc/v.digit/toolbox.tcl", 0x0}
        toolbox = "/usr/local/src/grass/grass63/dist.i686-pc-linux-gnu/etc/v.digit/toolbox.tcl\000\024\000\000\000$\000\000\000 l\001@úä\026@úä\026@h\227\030@\000\000\000\000ö¿\000@\000\000\000\000 l\001@\000\000\000\000Aû\000@ l\001@\220òÿ¿)L\025@Äæÿ¿\t«\000@\001\000\000\000 l\001@ðæÿ¿\224\033\030@Ôæÿ¿gü\000@\b\000\000\000\024\000\000\000 l\001@Äòÿ¿\233®\000@\024\000\000\000$\000\000\000\214òÿ¿"...
(gdb)

Hamish