ActiveState Community

Wrapped Tcl EXE crashes when loading byte compiled Tcl

Posted by martindrapeau on 2009-06-12 07:14

I have the latest TclDevKit 8.5 and have wrapped a Tcl script and base-tk8.5-thread-win32-ix86.exe. When run, my wrapped script attempts to source unwrapped Tcl files. If those are clear text it works fine. But when they are byte compiled the application crashes. Any idea?
I'm compiling using tclcompiler.exe. And why is there a tclcompiler84.exe in the bin directory as well? Same problem occurs with that version too.

And I see the tbcload package is versioned 1.7. Yet the byte compiled code requires 1.6. Here's a sample:

if {[catch {package require tbcload 1.6} err] == 1} {
return -code error "[info script]: The TclPro ByteCode Loader is not available or does not support the correct version -- $err"
}
tbcload::bceval {
TclPro ByteCode 2 0 1.7 8.5
...

Why is that?

--Martin

andreas.kupries | Fri, 2009-06-12 11:56

(1) tbcload 1.6 vs 1.7.
Tcl's package management considers the 1.6 in this 'package
require' command as advisory, the _minimum_ version of the package
required to run the script, and thus will load any higher version
of the package which has the same major version number, i.e. 1.6,
1.7, etc. but not 2.x. Change of major version is considered have
incompatible changes. tbcload 1.7 satisifies that and is therefore
used.

(2) tclcompiler vs tclcompiler84.

Between Tcl 8.4 and Tcl 8.5 the maintainers of the core made
changes to the byte code. This means that byte codes for 8.5 cannot
be loaded into an Tcl 8.4 core. The reverse, using Tcl 8.4 byte
codes in Tcl 8.5 is possible however, as the changes were
extensions of the bytecodes.

Tclcompiler produces Tcl 8.5 bytecodes
Tclcoompiler84 produces Tcl 8.4 bytecodes

The latter is present to support all the people which are still
stuck on Tcl 8.4.

(3) TclDevKit 8.5 ... Does not exist.
I am guessing that you are refering to TDK 5.0.3,
in combination with ActiveTcl 8.5 ?

(4) The crash.

By choosing an 8.5 basekit TclApp should have generated 8.5 byte
codes, using its internal compiler. Otherwise it would use the
external tclcompiler84. It writes what it had chosen to the log,
if -verbose.

Even so, both 8.4 and 8.5 bytecodes should work with the 8.5
basekit.

I believe that we will need more information here, like project
files, log output of TclApp, etc.

Our bug tracker, the canonical place to put such things, can be
found at http://bugs.activestate.com/

andreas.kupries | Fri, 2009-06-12 13:39

Another question.

When you say 'crash', are you talking about a C-level segmentation fault, bus error, and the like ?

Or are you talking about the application popping up a Tk error dialog containing a Tcl-level stack trace ?

martindrapeau | Sat, 2009-06-13 10:46

(1) and (2) is what I expected. Thanks for confirming.

I am using TclDevKit 5.0.2 and ActiveTcl 8.5.7.

A true crash occurs. Debugging in Visual Studio I get this: Unhandled exception at 0x0047d548 in test.exe: 0xC0000005: Access violation writing location 0x01010001.

I logged a bug with my test case: ID 83382.

Thanks,

--Martin