[Xotcl] Re: found bug

Gustaf Neumann Gustaf.Neumann@wu-wien.ac.at
Mon, 22 Jan 2001 14:51:36 +0100 (CET)


>>>>> "KL" == Kristoffer Lawson <setok@fishpool.com> writes:
KL> [~] package require XOTcl 
KL> 0.83
KL> [~] Class Foo
KL> [~] Foo instproc init {} { Bar [self] }
KL> [~] Foo instproc destroy {} { puts rm }

KL> [~] Class Bar
KL> [~] Bar instproc init {blah} {}

KL> [~] Foo ob
KL> rm
KL> no value given for parameter "blah" to "init"
KL> while evaluating {Foo ob}
KL> [~] Foo uh
KL> rm
KL> Segmentation fault

KL> The "Bar [self]" line was actually a bug in my own code (oops, forgot
KL> "new"), but it's interesting to note that it resulted in a segmentation
KL> fault.

 just to paraphrase the code: during the constructor of Foo, you
 created a new object of class Bar with the name of the instance of
 Foo. when you create a new command with the same name, the "old"
 object is deleted, and the constructor for the new command is called.
 but the constructor for the new object is called incorrectly, since
 the parameter "blah" was not provided.
 
 During the output of the error message, XOTcl tries to provide
 the backtrace (callstack), but it this case it contains a command
 from an non-existing object. 

 on my system, i do not get an segfault, but an output containing freed 
 memory. if you remove the "blah" argument from the constructor of 
 Bar, i would expect a graceful behavior on your system as well.

 If you are interested, i could send you a quick fix for the problem.
 However, I experimented with the problem, you are addressing, and 
 found another related problem, for which i have no fix yet....

 -gustaf