errorInfo has duplicate stack entries for autoloaded procs
Closed / Duplicate218347ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:33
OriginalBugID: 4058 Bug
Version: 8.2.3
SubmitDate: '2000-01-21'
LastModified: '2000-03-06'
Severity: MED
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: Linux-Red Hat
OSVersion: RedHat Linux 5.2, Kernel 2.0.36
Machine: Pentium, Pentium II
FixedDate: '2000-10-25'
ClosedDate: '2000-03-06'
Name:
Usman Muzaffar
Extensions:
no extensions, Tcl 8.2.3 (and 8.0.3) out of the box
CustomShell:
no modifications
Comments:
I found this while trying to write a catch phrase that reformats
the contents of errorInfo. I simply needed access to the stack at
the time of error. errorInfo of course seemed ideal, but I kept noticing
duplicate entries.
ReproducibleScript:
The problem is simply that if a function foo contains an error, the
errorInfo stack strace from will incorrectly list 'foo' TWICE, if both
of the following conditions are true:
1. foo is automatically sourced
2. foo is passed arguments that extend over multiple line
Two files are needed to show the problems:
proc2.tcl:::::::::::::::::
proc proc2 {x} {
error "proc2 error"
}
main.tcl:::::::::::::::::::
set auto_index(proc2) {source ./proc2.tcl}
proc proc1 {x} {
error "proc1 error"
}
proc main {} {
proc2 {
bogus
}
}
main
Run program ::::::::::::::::
% tclsh main.tcl
ObservedBehavior:
This is what you get when you run main.tcl.
Notice that proc2 is listed in the stack trace TWICE.
proc2 error
while executing
"error "proc2 error""
(procedure "proc2" line 2)
invoked from within
"proc2 {
invoked from within
"proc2 {
bogus
}"
(procedure "main" line 2)
invoked from within
"main"
(file "main.tcl" line 11)
DesiredBehavior:
What I expect is to see proc2 listed only once. In main.tcl change
the call 'proc2' to 'proc1' in the procedure 'main'. proc1 is identical
to proc2, but it's not dynamically loaded. This time you get:
proc1 error
while executing
"error "proc1 error""
(procedure "proc1" line 2)
invoked from within
"proc1 {
bogus
}"
(procedure "main" line 2)
invoked from within
"main"
(file "main.tcl" line 11)
Note that proc1 is only on the stack once. Interestingly, if you call proc2
(the dynamic proc), but don't include the newlines around it's argument,
you also get a correct errorInfo.
Delete the newlines around the word 'bogus', so that the body of 'main'
looks like this:
proc2 {bogus }
Now run:proc2 error
while executing
"error "proc2 error""
(procedure "proc2" line 2)
invoked from within
"proc2 {bogus }"
(procedure "main" line 2)
invoked from within
"main"
(file "main.tcl" line 9)
Which is what I'd expect. So it would seem that both the conditions listed above
must be true: 1) the proc must be dynamically loaded and 2) it must be
called with args that span newlines.
For error cases, it is arguable whether the errorInfo should include
data that indicates use of unknown. This has been the way in the past,
and we're going to leave it that way (it does after all indicate a
different path taken, which is the case). The spanning of newlines
is a red herring, because for that line only the first line of the
calling proc is included (errorInfo doesn't not contain all info).
-- 03/06/2000 hobbs
welch Closed ticket [218347ffff].
[History diff]2000-10-26 08:20:07
dgpplain2001-04-23 03:55:49
Logged In: YES user_id=80530 Duplicates 219280
Log in (anonymous is fine) to add a comment.