Overview
| Artifact ID: | 7a3beb4919d40d8f42389471c8ae703f8da5d970 |
|---|---|
| Ticket: | 3588687fffffffffffffffffffffffffffffffff
Tcl_InitStubs() Broken As Designed |
| User & Date: | nijtmans on 2012-12-07 03:27:40 |
Changes
- icomment:
Let's do an experiment, to show what I want to tell. Please check out the branche "novem-support". It is a modified 8.6, mainly pkgb.so is modified to use Tcl_PkgRequireEx(..., "8.6-". ...), and uses the Tcl_EvalEx() function. Clearly this is wrong: It would allow pkgb.so to be loaded by both Tcl 8.6 and Tcl 9.0, but Tcl_EvalEx will have a different signature, so that will lead to a crash. I'll show that. Then there is the branch "novem-demo-bug-3588687", which is a modified "novem" with a Tcl_EvalEx signature change: the numBytes parameter is changed to a Tcl_WideInt (will be size_t in Tcl9, but this way I can demonstrate the crash on 32-bit platforms as well) Let's run this tclsh9.0 and load the pkgb.so from the "novem-support" 8.6 build: $ tclsh9.0 % load ../../tcl8.6/unix/dltest/pkgb.so % info commands pkgb_* pkgb_unsafe pkgb_sub % pkgb_unsafe Crash! Aborted (core dumped) $ This pkgb.so was compiled and linked against the unmodified Tcl 8.6 tcl.h and libtclstub86.a. How come that this was not detected? Whatever test in tclStubLib.c cannot detect that: pkgb.so was compiled with a legacy stub library. So, the only way I see to make Tcl_StubInit give a nice error message is change the TCL_STUB_MAGIC magic value for 64-bit builds in Tcl9. Then, even though pkgb.so was linked with a legacy stub library it would detect that and give: "interpreter uses an incompatible stubs mechanism" in stead of crashing. If you have another idea how to prevent a crash in this case, I'm all ear. That's why my conclusion is that TCL_STUB_MAGIC should change on 64-bit platforms, it can stay the same on 32-bit platforms. Do you get the point from this? Regards, Jan Nijtmans - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"