Serious BLT 2.3 bug (long) 
Author Message
 Serious BLT 2.3 bug (long)

I have been plagued by a serious BLT error for the last couple of
months.  Basically, I have gone out on a limb, baffling and
amazing the locals with my tcl/tk project, scheduled  to ship a
workstation this month.  Unfortunately, I have been having some core
dumps; after displaying about 30-50 graphs, my interpreter blows up.

My actual interpreter includes itcl2.2, tcl7.6p2, tk4.2p2, BLT2.3,
sybtcl2.4, and a couple of thousand quite well tested lines of our
code.  My problems occur under SGI IRIX 5.3 as well as HP-UX 10.20,
which pretty nicely eliminates configuration and operating system
problems.  Anyway, the HP de{*filter*} suggests that the interpreter is
pretty much destroyed at the time of the core dumps; the tcl/tk
hash tables (or hash code) are history.

I have boiled down the problem code to the following small test program,
which fails under bltwish.  This test program plots many more graphs
than our larger workstation before failing, but the de{*filter*} shows
a very similar state of the interpreter at death, so I have high
hopes that fixing one will fix the other.  This script fails under
HP-UX, IRIX, and Linux.

---------------------------------------------------
#!../../blt2.3/bltwish

#       tstg4: shows bug in BLT 2.3; core dumps after a while
#       T. Wallace, 9/11/97

proc plt1 {} {
  global plotnum

  ::blt::graph .g -title $plotnum
  incr plotnum
  puts $plotnum

  .g element create line -xdata {1 2 3 4} -ydata {2 8 6 5} -pixels 0
-label ""
  pack .g
  after 500 {
        destroy .g
        plt1
  }

Quote:
}

set plotnum 0

plt1
---------------------------------------------------

I have now run this guy on HP-UX three times.  The first time, it
displayed
24750 graphs before dumping a 17.5 MB core.  The second time, it
froze at the 44389th iteration, with no numbers to the console,
the tk window blank, a process size of around 28MB, and no CPU time
being consumed.  The third time I ran it with the de{*filter*} overnight
and it got a bus error after only 6154 graphs.  (The first two times
I replaced "after 500" with "after 50" to make it go faster).
Under Linux and IRIX, it seems to fail faster; Linux was failing after
less than 1000 iterations.

Debugging this last dump, I found that the fatal call sequence
started when Itcl_EvalArgs called GraphWidgetCmd which went
to CreateOp -> CreateElement ->Blt_ConfigureWidgetComponent.
At this point, the graphPtr pointer and corresponding structure
is in good shape, as is the tkwin pointer.  The problem manifests
itself in the next two calls

  Tk_ConfigureWidget -> DoConfig

These routines are part of Tk, not BLT, and when we re-enter the BLT
routines as DoConfig -> PenParse the code uses the tkwin pointer
as in line 186 of the file bltGrPen.c:

  graphPtr = Blt_FindGraph(tkwin);

to locate the graphPtr.  Unfortunately, the hash tables have been
wiped out, so although the tkwin pointer is correct the graphPtr
which is returned is garbage, and the resulting failure often seems
to be in a line of code like:

  hPtr = Tcl_FindHashEntry(&(graphPtr->penTable), name);

( in line 246 of the file bltGrPen.c;
the rest of the calling sequence looks lik
  PenParse -> Blt_GetPen -> NameTo_pen.)

Incidentally, those last three routines called through DoConfig
are not always the same ones, but the ones shown above in this
last example are exactly the same ones which I saw in my very first
trip through the de{*filter*} with my big custom interpreter and big
workstation code, after 40 mouse clicks to display graphs.

The memory appears to leak about 600 bytes per graph, which is
not a major crisis for our application since the display of more
than a couple of thousand graphs without resetting is unlikely,
but someone might be able to find the leak(s) with this test program
as well.  Incidentally, a tk script using canvases to plot the
same data (but without the axes) seems to run forever, and never
leaks any memory.

I emailed the author, but he doesn't seem to be answering.

Thanks for any help,

--Tim

Tim Wallace, MIT Lincoln Laboratory, Lexington MA 02173
twallace at ll dot mit dot edu



Mon, 03 Apr 2000 03:00:00 GMT  
 Serious BLT 2.3 bug (long)

Quote:

> I have been plagued by a serious BLT error for the last couple of
> months.  Basically, I have gone out on a limb, baffling and
> amazing the locals with my tcl/tk project, scheduled  to ship a
> workstation this month.  Unfortunately, I have been having some core
> dumps; after displaying about 30-50 graphs, my interpreter blows up.

> and it got a bus error after only 6154 graphs.  (The first two times
> I replaced "after 500" with "after 50" to make it go faster).
> Under Linux and IRIX, it seems to fail faster; Linux was failing after
> less than 1000 iterations.

A data point:

Linux 2.0.30, Redhat 4.1 tcl-7.6-2 tk-4.2-2 blt-1.9-5 (i.e. no itcl or other
packages) ; your script modified to not use namespaces did 8723 iterations
before I killed it.



Tue, 04 Apr 2000 03:00:00 GMT  
 Serious BLT 2.3 bug (long)

Quote:


> > I have been plagued by a serious BLT error for the last couple of
> > and it got a bus error after only 6154 graphs.  (The first two times
> > I replaced "after 500" with "after 50" to make it go faster).
> > Under Linux and IRIX, it seems to fail faster; Linux was failing after
> > less than 1000 iterations.

> A data point:

> Linux 2.0.30, Redhat 4.1 tcl-7.6-2 tk-4.2-2 blt-1.9-5 (i.e. no itcl or other
> packages) ; your script modified to not use namespaces did 8723 iterations
> before I killed it.

Interesting indeed; my original post was long enough, so I didn't
mention that
my Linux runs involved your exact same setup, except blt 2.3!  I also
ran a
non-namespace version of the script.  Did your bltwish leak any memory
as
it ran?  If not, it sounds like downgrading to a previous version of BLT
could solve my problems.  Some of the C API stuff is different, but I
could
handle it.  Itcl and Sybtcl are definitely not at fault.


Tue, 04 Apr 2000 03:00:00 GMT  
 Serious BLT 2.3 bug (long)

: I have been plagued by a serious BLT error for the last couple of
: months.  Basically, I have gone out on a limb, baffling and
: amazing the locals with my tcl/tk project, scheduled  to ship a
: workstation this month.  Unfortunately, I have been having some core
: dumps; after displaying about 30-50 graphs, my interpreter blows up.

The entry in a global hash table was not being removed when the graph
widget was destroyed.  Depending upon your memory allocator, you can
get an address for a Tk window which isn't a graph widget.  

: The memory appears to leak about 600 bytes per graph, which is
: not a major crisis for our application since the display of more
: than a couple of thousand graphs without resetting is unlikely,
: but someone might be able to find the leak(s) with this test program
: as well.  Incidentally, a tk script using canvases to plot the
: same data (but without the axes) seems to run forever, and never
: leaks any memory.

Two GCs were not getting released properly.  

I've included a patch below for both problems.  You should probably do
a "make clean" first.

: I emailed the author, but he doesn't seem to be answering.

No, sometimes he gets really busy and forgets.

Thanks for the script and diagnostics.  It really helped. I wasn't
likely to find in this bug in any of my testing.

I really appreciate it.

--gah

*** blt2.3/src/bltGraph.c       Thu Jun 26 14:21:38 1997
--- blt2.3p/src/bltGraph.c      Fri Oct 17 18:47:39 1997
***************
*** 601,606 ****
--- 601,612 ----
      if (graphPtr->fillGC != NULL) {
        Tk_FreeGC(graphPtr->display, graphPtr->fillGC);
      }
+     if (graphPtr->plotFillGC != NULL) {
+       Tk_FreeGC(graphPtr->display, graphPtr->plotFillGC);
+     }
+     if (graphPtr->titleGC != NULL) {
+       Tk_FreeGC(graphPtr->display, graphPtr->titleGC);
+     }
      if (graphPtr->elemCache != None) {
        Tk_FreePixmap(graphPtr->display, graphPtr->elemCache);
      }
***************
*** 614,619 ****
--- 620,626 ----
        Blt_FreeTile(graphPtr->tile);
      }
      Tk_FreeOptions(configSpecs, (char *)graphPtr, graphPtr->display, 0);
+     Tcl_DeleteHashEntry(graphPtr->hashPtr);
      free((char *)graphPtr);
  }

***************
*** 645,651 ****
  {
      Graph *graphPtr;
      Tk_Window tkwin;
-     Tcl_HashEntry *hPtr;
      int dummy;

      if (!initialized) {
--- 652,657 ----
***************
*** 676,683 ****
      graphPtr->padLeft = graphPtr->padRight = 8;
      graphPtr->padTop = graphPtr->padBottom = 8;
      /* Add graph to hash table of graphs */
!     hPtr = Tcl_CreateHashEntry(&graphTable, (char *)tkwin, &dummy);
!     Tcl_SetHashValue(hPtr, (ClientData)graphPtr);

      Tcl_InitHashTable(&(graphPtr->axisTable), TCL_STRING_KEYS);
      Tcl_InitHashTable(&(graphPtr->elemTable), TCL_STRING_KEYS);
--- 682,689 ----
      graphPtr->padLeft = graphPtr->padRight = 8;
      graphPtr->padTop = graphPtr->padBottom = 8;
      /* Add graph to hash table of graphs */
!     graphPtr->hashPtr = Tcl_CreateHashEntry(&graphTable, (char *)tkwin, &dummy);
!     Tcl_SetHashValue(graphPtr->hashPtr, (ClientData)graphPtr);

      Tcl_InitHashTable(&(graphPtr->axisTable), TCL_STRING_KEYS);
      Tcl_InitHashTable(&(graphPtr->elemTable), TCL_STRING_KEYS);
diff -rc blt2.3/src/bltGraph.h blt2.3p/src/bltGraph.h
*** blt2.3/src/bltGraph.h       Thu Jun 26 14:21:39 1997
--- blt2.3p/src/bltGraph.h      Fri Oct 17 18:06:52 1997
***************
*** 371,376 ****
--- 371,377 ----
                                 * among other things, to release
                                 * resources after tkwin has already gone
                                 * away. */
+     Tcl_HashEntry *hashPtr;
      Tcl_Command cmdToken;     /* Token for graph's widget command. */

      Tk_Font font;             /* Font to use when drawing the graph title */



Wed, 05 Apr 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. BUG: BLT 2.3 needs prodding to see vectors

2. BLT 2.3: Vector bug fix

3. Blt 2.3: One Bug, One Feature, Two Solutions :)

4. BLT 2.3

5. BLT 2.3 under AIX

6. BLT 2.3 for AIX

7. BLT 2.3 for Tcl/Tk 8.0

8. BLT 2.3/itcl2.2?

9. ANNOUNCE: BLT 2.3 released

10. Mops 2.3 bug fixed

11. Bug in struct.pack() for Sparc Solaris 2.3?

12. 2.3 a1 True/False bug in tkinter?

 

 
Powered by phpBB® Forum Software