Menu

#213 ItclContext size too small

3.4
closed-fixed
5
2011-07-08
2011-07-08
No

When compiling Itcl 3.4 using Tcl 8.5 and running it with Tcl 8.6, then running the test cases:

Tests began at Fri Jul 08 08:52:28 CEST 2011
basic.test

==== basic-5.6a variable accesses variables within namespace FAILED
==== Contents of test case:

list [catch {test_globals::getval g1} msg] $msg

---- Result was:
0 {}
---- Result should have been (exact matching):
0 global1
==== basic-5.6a FAILED
.........
==== namespace-1.4 create an object in another namespace FAILED
==== Contents of test case:

namespace eval test_ns_2 {
list [Counter c] [c ++] [c ++] [c ++] [c ++]
}

---- Result was:
c 1 2 2 2
---- Result should have been (exact matching):
c 1 2 4 8
==== namespace-1.4 FAILED

protection.test
scope.test

Tests ended at Fri Jul 08 08:52:57 CEST 2011
all.tcl: Total 400 Passed 362 Skipped 0 Failed 38

The reason for this is that the ItclContext structure is too small
in this situation: The reason: ItclContext uses ItclCallFrame as
one of its structure members, but in Tcl8.6 this member has
an extra field added. This field overwrites the compiledLocals
field whenever the (Tcl_Push|Pop)CallFrame function pair
is used on this CallFrame.

Solution: Use Itcl_CallFrame (which maps to Tcl_CallFrame)
in stead of TclCallFrame, which is modified to contain those
extra (dummy) fields, exactly to prevent this very problem.

Here is the patch which fixes this.

Discussion

  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    proposed fix

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08
    • assigned_to: davygrvy --> dgp
     
  • Don Porter

    Don Porter - 2011-07-08

    Any tips how I can reproduce this?

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    >Any tips how I can reproduce this?

    Since your checkin [cc1cf10c58] form yesterday, this
    bug is fixed as well. But I don't agree with simply
    copying structure definitions from tclXxx.h to
    itclXxx.h.

    So, reproducing goes as follows: revert [cc1cf10c58]
    and then apply this patch. Much simpler..... It
    fixes the same thing.

    I already created this patch yesterday, but put
    it in SF today, without checking your cuncurrent work.

    Regards,
    Jan Nijtmans

     
  • Don Porter

    Don Porter - 2011-07-08

    aha! That makes more sense. Will look it over.

     
  • Don Porter

    Don Porter - 2011-07-08

    Committed what appears to be correct.
    It tests ok for me. Please confirm.

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    Yes, this is how it always should have be. With the tip of core-8.4-branch and
    any later Tcl version, this should always work fine.

    However, this depends on Tcl 8.4 since [541d313d64] (2010-07-25). If you
    compile Itcl 3.4 against released Tcl 8.4.19 and running it against
    Tcl 8.5/8.6, the same crash will still happen.

    That's why I would recommend to bring out Tcl 8.4.20 before Itcl 3.4.1,
    and simply state that Tcl 3.4.1 must be compiled against Tcl 8.4.20+
    in order to work with all later Tcl versions.

    But it's up to you. We can also provde the Itcl_CallFrame replacement
    when compiling against Tcl 8.4 only, then we are always on the
    safe side.

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    This final patch (itcl-safest.patch) makes it work with
    all earlier Tcl 8.4 versions as well, not only the tip of
    the core-8-4-branch, that's what I would do.

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    make it work against Tcl 8.4.19 and earlier

     
  • Jan Nijtmans

    Jan Nijtmans - 2011-07-08

    Oops, wrong cut-paste. Here is the correct one!

     
  • Don Porter

    Don Porter - 2011-07-08
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB