Itcl - the [incr Tcl] extension

View Ticket
Login
Ticket Hash: 2cd667f270b68ef66d668338e09d144e20405e23
Title: private method name blocks instance name
Status: Closed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2015-12-11 18:54:41
Version Found In: ab0d27d5380786625dfa1807a494cb849179d4aa
User Comments:
anonymous added on 2014-04-09 01:15:06:
package require Itcl
itcl::class Naughty {private method die {} {}}
Naughty die

The above code SIGSEGVs.  Here's what I said about it on the Tcler's Chat:

[19:48]	<Unununium> I just hit a SIGSEGV in [incr Tcl], though appears to be in the TclOO guts.  Using the latest Fossil of everything.  Tcl_ObjectGetMetadata() is returning NULL which is later dereferenced.
[19:50]	<Unununium> Critical line in Tcl_ObjectGetMetadata() is hPtr = Tcl_FindHashEntry(oPtr->metadataPtr, (char *) typePtr);
[19:50]	<Unununium> typePtr->name is "ItclObject"
[19:51]	<Unununium> oPtr->metadataPtr only has one entry in it at this point
[19:52]	<Unununium> The one and only entry is for "ItclClass"
[19:52]	<Unununium> As determined by groveling through RAM using gdb

arnulf added on 2014-09-13 16:51:08:
Fixed in trunk, will go into next release.

dgp added on 2015-06-04 13:16:24:
Re-opened this one.  The prior work on this report
stopped a segfault, and that's good.

However it didn't make the code actually work.

Contrast Itcl 3 with Itcl 4:

% package require Itcl
3.4
% itcl::class Class {private method instance {} {}}
% Class instance                                                                
instance                     


% package require Itcl
4.0.3
% itcl::class Class {private method instance {} {}}
% Class instance
invalid command name "instance"

dgp added on 2015-06-04 13:17:34:
Try that again....

% package require Itcl
3.4
% itcl::class Class {private method instance {} {}}
% Class instance                                                                
instance           

% package require Itcl
4.0.3
% itcl::class Class {private method instance {} {}}
% Class instance
invalid command name "instance"

dgp added on 2015-06-04 13:19:05:
Why is the ticket system inserting a newline?!?!

% package require Itcl
3.4
% itcl::class Class {private method instance {} {}}
% Class instance                                                                
instance          


Ok, i've just checked with the Preview, and it previews ok.

dgp added on 2015-06-04 13:19:37:
AAAARGRGRGRGRGRRHRRRHHHHHH!!!!!


And then I Submit and it's busted again.

Preview lies.

dgp added on 2015-06-04 13:25:26:
% package require Itcl
3.4
% itcl::class Foo {private method bar {} {}}
% Foo bar
bar

dgp added on 2015-06-04 13:26:10:
% package require Itcl
4.0.3
% itcl::class Foo {private method bar {} {}}
% Foo bar
invalid command name "bar"

dgp added on 2015-06-04 13:27:55:
Anyhow, hopefully through all the ticket mangling you can
see that there's a confusion lurking about the methods
of an instance and the methods of the class object that
creates an instance.  restrictions on one should not interfere
with the other.

dgp added on 2015-12-11 18:54:41:
fixed on trunk.