Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000340graphvizDotty/Lneato/Leftypublic2004-02-20 21:172011-04-28 04:02
ReporterDavid Wallace 
Assigned Togviz 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSx86-Windows-Win98OS Version
Summary0000340: "Lefty PANIC: bad key" on Win98
Description



My application (about 3K lines of lefty code running on top of Dotty) encounters a popup with a "Lefty PANIC" title and the "bad key" message from time to time, followed by a crash of all Dotty windows. MS Visual C++ then reports a runtime error with abnormal program termination in lefty.exe, but I don't have further info (I just have a binary distribution of graphviz). The effect is repeatable with the exact same series of steps, but minor variations run fine. The latest instance for me occurs when I run a particular Lefty script against one particular graph (a small graph, as is the new graph the script is generating) in batch mode. However, either turning on my verbose flag in the function being called (which runs the exact same code with a few calls to echo enabled to provide status), or loading the script against the same graph from the lefty window instead of a DOS command line causes the script to run successfully.
Unfortunately, I really need this script to run uninterrupted from the command line to get accurate timing data.
Additional Information
Because of the elusive nature of this bug, it's almost impossible to winnow it down to a small example, and I'm not prepared to send my whole application. So duplication may be a problem - I'm hoping you've encountered something like it in another lefty application, or can at least suggest likely causes by looking at the source (I have a binary distribution only). I've sent a screen shot along (16 color bitmap) to show the popup window along with the window from which I'm invoking the script.

[ek] the 'bad key' panic happens when you try to insert/find/delete
something in a table, and the key you provide is a non-scalar,
e.g. another table. the interpreter is supposed to check for this
and emit a runtime error, so this shouldn't happen from a lefty
script. it could happen from a builtin function, like the graph
read/write functions. it's strange that it's not consistent though.

a couple things to do.

set the environment variable LEFTYOPTIONS to say '-el 2'.
that prints more verbose error messages from the interpreter.
won't help if it's a builtin function problem. and you'll
break your finger clicking 'ok' for each message (it uses
a popup).

[dave]
The problem is that Mdogc (in mem.c)
is being called while the interpreter is in the middle of the
eforinst loop, and the table being iterated over is one of the
blocks of memory that gets Mfree called on it in Mdogc.
In particular, the value of otarray[1][79735] during the
loop from i=0 to prevoti (= 79739)) is equal to the
address of the table. So the memory gets scribbled on by the
call to Mfree, and then it gets reused shortly thereafter,
while the eforinst loop is still going on --> crash.

I suspect that this bug is behind most, if not all, of the
various crashes I have observed. I don't know if there is a quick
fix - clearly, any data that is actively being referenced
by the interpreter needs to be protected from being relocated/freed
in Mdogc. I haven't probed deeply enough into the data structures
to see what precautions you are already taking. One possibility
is to increment/decrement object reference counts as the
interpreter uses the objects.

TagsNo tags attached.
AUXILLARY-FILES
DATE-FIXED
FIX-COMMENT
FORMER-ID406
INPUT-FILEhttp://www.graphviz.org/bugs/b406.dot [^]
OUTPUT-FILEhttp://www.graphviz.org/bugs/b406.jpg [^]
STATUS-COMMENTFixed (4 March 2004)
VERSION     1.9 (or 1.10)
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2011-04-28 04:02 user1 New Issue
2011-04-28 04:02 user1 Assigned To => user1


MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker