|
2000-10-26
| ||
| 08:33 | • Closed ticket [218982ffff]: Unsetting array with element traces causes Tcl to ab... artifact: 70793d5242 user: welch | |
| 01:08 | • New ticket [218982ffff]. artifact: cf8645dafd user: nobody | |
Unsetting array with element traces causes Tcl to abort
Closed / Fixed218982ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:08:55
OriginalBugID: 3453 Bug
Version: 8.0p2
SubmitDate: '1999-11-05'
LastModified: '2000-01-14'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: ericm
OS: Solaris
OSVersion: 2.6
FixedDate: '2000-01-14'
FixedInVersion: 8.3
ClosedDate: '2000-10-25'
Name:
Mark A. Wege
Comments:
The code also fails under Tcl 7.4.
The code does NOT fail if the array variable is unset in a procedure
instead of the global scope. It also doesn't fail if you remove the
global statement from the showtrace procedure.
ReproducibleScript:
The following script is a part of some code I've written to help people
track down problems in their code by setting traces on variables to see
where their values are being changed. To execute this, either execute
tclsh interactively and paste this code into the session, or place the
code into a file and then execute tclsh with the file as a parameter:
proc showtrace {var ind op} {
global t
puts "showtrace: var = $var ind = $ind op = $op"
}
set t(1) 1
trace variable t(1) u showtrace
unset t
ObservedBehavior:
When the code is executed, tclsh provides the following output and
then crashes:
showtrace: var = t ind = 1 op = u
malformed bucket chain in Tcl_DeleteHashEntry
Abort (core dumped)
DesiredBehavior:
Tcl should be able to unset the array variable without crashing.
Confirmed in 8.2.2. Workaround is to explicitly unset t(1)
first (or foreach over array names).
-- 11/10/1999 hobbs
The root of this problem had to do with a failure to protect the array variable from being deleted multiple times, which was implicitly happening in the code shown: once for the unset, and once when the call stack was popped after finishing the showtrace function. Of course, free'ing a block of memory twice is never a good thing, and this ultimately led to the core dump.
I fixed the bug by putting protection against this situation in the unset code. The fix will go into 8.3.
- eric
-- 01/14/2000 ericm
welch Closed ticket [218982ffff].
[History diff]2000-10-26 08:33:07
Log in (anonymous is fine) to add a comment.