Menu

#99 vector namespace conflict leads to seg fault

open
nobody
None
5
2003-08-01
2003-08-01
No

Seg fault caused by the following script, Tcl/Tk 8.3.5,
BLT2.4v-z, Linux & Sun.

Within a certain namespace, repeatedly create (or dup)
a vector that has the same tail name as a vector in the
global namespace.

-----------------------------------------------
package require BLT

namespace eval a {
proc nameconflict {} {

# this method probably contains a bug: it should
delete the local
# problem vector once it is done with it. still, an
error message
# from [blt::vector create] would be better than a
seg fault -- and,
# it's interesting to note that a repeated
# blt::vector create ::a::problem
# will never cause a seg fault here.
blt::vector create problem

puts "created local problem vector\n[blt::vector
names]"
set pi 3.1415927
}
}

blt::vector create problem
puts "created global problem vector\n[blt::vector
names]"
for {set i 0} {$i < 100} {incr i} {
a::nameconflict
}
blt::vector destroy problem
-----------------------------------------------

The line "blt::vector create problem" may be replaced by
a dup command (from some global vector, perhaps) with
the same result -- and the dup command is documented
to allow a pre-existing destination vector.

Any number of trivial changes cause the seg fault to go
away -- for example, fully qualifying the local problem
vector name (::a::problem), destroying the vector at
the end of the method, or even commenting out the "set
pi" command. However, this particular script, on my
systems, reliably causes a seg fault on the third iteration
of the master loop.

I didn't look into a C solution (yet) since fully qualifying
the vector namespaces avoids the core dump and is
what I should be doing anyway...

Karl

Discussion


Log in to post a comment.