Artifacts Associated With Ticket 218145
Ticket change [28bc23b340] (rid 88750) by nobody on 2000-10-26 00:53:44:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 2119 Bug Version: 8.1 SubmitDate: '1999-05-21' LastModified: '1999-05-26' Severity: CRIT Status: Closed Submitter: pat ChangedBy: redman OS: Windows NT OSVersion: 4.0sp3 Machine: X86 FixedDate: '2000-10-25' FixedInVersion: NA ClosedDate: '1999-05-26' Name: vince darley ReproducibleScript: Consider a C++ dll with some global constructors (i.e. constructors which are automagically called when the .dll is loaded, before the <Pkg>_Init function is called). Now if those global constructors actually call Tcl, for instance if a 'cpp_mem' constuctor like the following is called: cpp_mem(const char* n=0) { if(n) { _name = Tcl_NewStringObj((char*)n,-1); Tcl_IncrRefCount(_name); } } Now this works fine without stubs, since we can call Tcl_NewStringObj etc without knowing the Tcl interpreter which is going to be used. However, with stubs, since we haven't yet called 'Tcl_InitStubs', Tcl_NewStringObj is obviously going to give an access violation. This means the .dll fails to load, and the Tcl 'load' command returns the error message "invalid argument". The solution to this is to (i) avoid calling Tcl before the .dll is loaded (which is backwards incompatible, and removes what I find to be a useful feature), or (ii) call Tcl_InitStubs earlier. I view (i) as unacceptable, so let's try (ii): most platforms provide a (compiler/platform dependent) Dll-init function which will be called before the global constructors are, so we can call Tcl_InitStubs from that (on windows it's defined as 'BOOL APIENTRY DllEntryPoint(HINSTANCE hInst, DWORD reason, LPVOID reserved)', and must be defined by every dll). Unfortunately, we can't call Tcl_InitStubs correctly from that function, because we don't know the interpreter yet! If we try to call 'Tcl_InitStubs' with a null interpreter, it just returns an error, since it needs to get a valid interpreter from which to extract the stubs ptr. I'm not sure what the best solution is! There ought to be some way to get at the 'default' stubs table if such a thing exists. Unless this can be solved, my C++ extensions (Cpptcl, Plcpp, Cppmatrix..) cannot use Stubs... This is correct behavior. Option (i) in his report is the only reasonable thing to do. -- 05/26/1999 redman - foundin initialized to: "obsolete: 8.1"
- 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:
conflict between Stubs and C++ dlls with global constructors
- type initialized to: "Bug"
Ticket change [65258a997d] (rid 92904) by welch on 2000-10-26 08:15:56:
- closedate changed to: "2000-10-26T01:15:56"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [431fcf38bb] (rid 116492) by dgp on 2001-04-18 06:27:29:
- closedate changed to: "2001-04-17T23:27:29"
- closer changed to: "dgp"
- subsystem changed to: "40. Dynamic Loading"