TCL 8.5.8 crashes on exit
Closed / Invalid2931244fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 17 years ago
Descriptionplain2010-01-13 09:27:32
This does not happen on tcl8.5.7. Please see the attached testcase. just start tclsh % package require testPackage % exit And the crash occurs.
azarooplain2010-01-13 16:27:35
File Added - 358788: tclCrash858.tgz
ferrieuxplain2010-01-13 18:16:02
A bit of human-readable context would be appreciated. Basically you need a specific behavior from an extension to crash. Please summarize it.
azarooplain2010-01-13 18:31:57
I am not good at it, but let me try!
1. You need to compile the cpp file into a dll and modify the pkgIndex.tcl file accordingly to load the package.
2. The tclsh was compiled without threads.
The Crash Happens in the destructor
~TclFileHandles() {
Tcl_UnregisterChannel(0, chann);
Tcl_FSDeleteFile(channFileName);
Tcl_DecrRefCount(channFileName);
if (fp) { // hack as mentioned above
fclose(fp); unlink(fpFileName.c_str());
}
}
on Tcl_DecrRefCount(channFileName);
In a debugger, I could track it down to TclFreeObj function call where this problem was manifesting itself.
If you want some other info do let me know!
Regards,
ferrieuxplain2010-01-13 21:12:33
Uh, what I don't see is the link between the Tcl/extension API (XXX_Init and XXX_unload) and your C++ class's constructor and destructor. Maybe a file is missing ? Otherwise, how do you ensure that the constructor is called by Test_Init and (more importantly) the destructor by Test_Unload ?
azarooplain2010-01-13 21:52:04
Ok! Basically the load library call loads the dll and that is all is required. The Test_Init is just a stub and does not do anything. The Constructor is called as there are static members and the destructor will be called on unload of the dll. I hope that is it.
ferrieuxplain2010-01-13 22:57:02
OK so you destructor gets called by dlclose(), hence by TclFinalizeLoad, which is very late in the Tcl_Finalize sequence, notably *after* TclFinalizeObjects. Hence you shouldn't do any Tcl_Obj freeing, nor anything Tcl-oriented for that matter, in the destructor. Just do things that are related to (1) the outside side-effects of your extensions (created files or shared memory segments mainly), and (2) optionally private mallocs, and only if you want to use a vlagrind-like tool to hunt leaks. All the rest is guaranteed to be properly nuked by the normal finalization process.
ferrieux Closed ticket [2931244fff].
[History diff]2010-01-13 22:57:03
Log in (anonymous is fine) to add a comment.
Attachments:
- tclCrash858.tgz [download] added by azaroo on 2010-01-13 16:27:35. [details]