A bug - or so I think - in STk 2.1.4

From: <Michal.Jankowski_at_fuw.edu.pl>
Date: Sat, 3 Dec 94 13:04:32 +0100

I think I've found a bug in STk 2.1.4, as compiled on SunOS 4.1.3_U1,
(I have included a patch for this version which was posted here last
month.)

The following program bombs after 400-600 iterations and a couple of
garbage collects.

------cut here--------
#!/home/1/michalj/stk/stk-bin -f
(require "regexp")
(define n 0)
(define (getload node)
  (define ans " ccmj up 7 days, 23:01, load average: 0.11, 0.02, 0.00")
  (define hostload (regexp-replace " *(.[^ ]*).*: (.[0-9.]*),.*" ans "\\1 \\2"))
  (set! n (+ n 1))
  (after 100)
  (string-append hostload ":" (number->string n))
  )

(toplevel '.fc :geometry "300x300")
(canvas '.fc.canvas :height 200 :width 200)
(pack .fc.canvas)
(.fc.canvas 'create 'line 0 0 50 50 )
(define (updateinfo)
  (.fc.canvas 'create 'rectangle 0 0 200 200 :fill 'white)
  (.fc.canvas 'create 'text 0 0 :anchor 'nw :text (getload "ccfs1"))
)
(define (displayloop)
  (updateinfo)
  (after 100 '(displayloop)))
(displayloop)

------cut here--------

It's actually a modified part of a larger program, and a shortest
piece of code that consistently fails.

The symptoms are usually:

*** Error:
bad screen distance "ccmj 0.11"
**** Tk error ("") ""

or

*** Error:
bad screen distance " \2"
**** Tk error ("") ""

I have verified (by inserting some 'printf's in tk_glue.c) that while
the loop initializing argv array is initially correctly processing the
list of arguments, by the time that list is passed to TK (line
  tkres = (*W->fct)(W->ptr, main_interp, argc, argv);
) it get's mangled to something like this

.fc.canvas : create : text : \2 : 0 : -anchor : nw : -text : ccmj 0.11:412 :

It appears that calling another function ('getload' in my example)
while tk_glue is processing a list of arguments to a tk-command leaves
some locations incorrectly open to a garbage collection.

There is a comment in tk_glue.c about conv_res being set-up to prevent
this kind of problems with gc. But appears it doesn't work - or
perhaps there is a bug somewhere else.

If you need any additional details, I'd be glad to help

  Michal
Received on Sat Dec 03 1994 - 13:05:37 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST