Artifacts Associated With Ticket 218530ffffffffff
Ticket change [1f466d6e80] (rid 91122) by nobody on 2000-10-26 01:01:46:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 913 Bug Version: 8.0.3 SubmitDate: '1998-12-04' LastModified: '1999-04-16' Severity: LOW Status: Released Submitter: welch ChangedBy: stanton OS: Windows NT OSVersion: NT4.0 SP3 Machine: X86 FixedDate: '1999-04-16' FixedInVersion: 8.1b3 ClosedDate: '2000-10-25' Name: Jan Nijtmans CustomShell: plus-patch. But because this problem is ReproducibleScript: - produce a standalone executable on a system which doesn't support backlinking (e.g. Windows 95/98/NT). (I did this with the plus-patch, but since this problem is generic I am sure that the TclPro wrapper has the same problem) - dynamicaly load any extension (e.g. "package require Tix") ObservedBehavior: Unhandled exception. The stack trace in the above described case looks like (although I doubt it is useful) TK80! 00cafaa2() TIX4180! 10019d92() WISH80S! 0040e097() WISH80S! 0043f879() WISH80S! 0040e966() WISH80S! 0040e72f() WISH80S! 0040fc0c() WISH80S! 004133f5() WISH80S! 0041322a() WISH80S! 00413a1e() WISH80S! 0040e097() WISH80S! 0043f879() WISH80S! 0040e966() WISH80S! 0040fc3c() WISH80S! 00413103() WISH80S! 00412ff3() WISH80S! 00401941() WISH80S! 0040e097() WISH80S! 0043f879() WISH80S! 0040e966() WISH80S! 0041fbcb() WISH80S! 0043f879() WISH80S! 0040e966() WISH80S! 0040e72f() WISH80S! 0040fc0c() WISH80S! 004787f0() WISH80S! 004678fd() WISH80S! 0044bb61() WISH80S! 0044be36() WISH80S! 0041a9ff() WISH80S! 0041ac9d() WISH80S! 0044bea0() WISH80S! 004010b8() WISH80S! 00402146() KERNEL32! 77f1b304() DesiredBehavior: nice error message: "Cannot load package in statically linked executable", or something like that. The patch below is able to catch this kind of error, before anything bad happens. (The same can happen with any global variable in tcl.dll or tk.dll, but tclEmptyStringRep is the easiest to check for). I tested this on Windows NT4/SP3. Patch: *** generic/tclPkg.c.origThu Apr 02 00:39:49 1998 --- generic/tclPkg.cTue Nov 17 15:29:57 1998 *************** *** 150,155 **** --- 150,173 ---- Tcl_DString command; /* + * Test if global variables are correctly initialized. If not, + * the only explanation is that we are trying to load a binary + * package into a statically linked executable on a system + * which doesn't support backlinking (e.g. Windows, AIX). In + * that case there are two global variables "tclEmptyStringRep": + * one in the static executable and one in the shared Tcl + * library. If we are addressing the wrong one here (and that + * is what happens if we try dynamical loading), it's better + * to produce a nice error message, than having a crash later. + */ + + if (!tclEmptyStringRep) { + Tcl_AppendResult(interp, "Cannot load package \"", name, + "\" in statically linked executable", NULL); + return NULL; + } + + /* * It can take up to three passes to find the package: one pass to * run the "package unknown" script, one to run the "package ifneeded" * script for a specific version, and a final pass to lookup the PatchFiles: tclPkg.c Explanation how this solution works: If the system doesn't support backlinking, there are two global variables "tclEmptyStringRep": one in the static executable and one in the shared Tcl library. If the function Tcl_PkgRequire() (which is usually the first function in the extension) is executing in a only partly initialized dll, that is asking for trouble. On AIX it is currently impossible to do this, because --disable-load is coupled with --enable-shared. With this change, it would be possible to remove this coupling: There will still an error message be generated if the used tries to do dynamical loading. (B.T.W, it is possible to produce libraries which can be dynamically loaded on AIX in statically linked executables. Paul Duffin is working on that, with very good results) This is incorporated by the stubs patches. 04/16/1999 14:44 - stanton - - foundin initialized to: "obsolete: 8.0.3"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "dynamical linking in standalone executables"
- type initialized to: "Bug"
Ticket change [e357d31bd4] (rid 87781) by welch on 2000-10-26 08:24:12:
- closedate changed to: "2000-10-26T01:24:12"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [efb41f3097] (rid 109047) by dgp on 2001-04-16 21:07:33:
- closedate changed to: "2001-04-16T14:07:33"
- closer changed to: "dgp"
- subsystem changed to: "39. Package Manager"
Ticket change [6026fd5ce2] (rid 115944) by dgp on 2001-11-02 08:20:54:
- assignee changed to: "nijtmans"
- closedate changed to: "2001-11-02T01:20:54"
- closer changed to: "dgp"
- icomment:
Logged In: YES user_id=80530 Moving this from Closed to Pending so I can get some feedback from Jan Nijtmans on it. As reported in Bug 476537 http://sf.net/tracker/?func=detail&aid=476537&group_id=10894&atid=110894 the patch in Bug Report 218530 has a problem (that may have arisen long after the patch was accepted) that when tclEmptyStringRep is invalid, the call to Tcl_AppendResult() will panic. Since I'm working on a fix for that problem anyway, I want to also update the comment describing the check so that programmers other than Jan Nijtmans and Paul Duffin can understand it! Bug Report 218530 contains more detail, so I'm understanding it better. I can see how two copies of a global variable can exist within the executable on a platform without backlinking support, but there are two things I don't understand 1) What does it mean for a DLL to be "partially initialized"? 2) How can it be that Tcl_PkgRequireEx() is referencing the wrong (uninitialized) tclEmptyStringRep variable? When Tcl_InitStubs(interp,version,exact) is called, the stubs pointer from interp is the one used to look up Tcl_PkgRequireEx, so both ought to be coming from the original executable. How is it that the Tcl_PkgRequireEx() in the original executable is somehow seeing an uninitialized tclEmptyStringRep, presumably from the improperly-stub-enabled shared library? I await enlightenment from Jan Nijtmans, or anyone else who wants to volunteer.
- login: "dgp"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "dgp"