Ticket UUID: | 2931244 | |||
Title: | TCL 8.5.8 crashes on exit | |||
Type: | Bug | Version: | obsolete: 8.5.8 | |
Submitter: | azaroo | Created on: | 2010-01-13 09:27:32 | |
Subsystem: | 10. Objects | Assigned To: | msofer | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2010-01-13 22:57:03 | |
Resolution: | Invalid | Closed By: | ferrieux | |
Closed on: | 2010-01-13 15:57:03 | |||
Description: |
This does not happen on tcl8.5.7. Please see the attached testcase. just start tclsh % package require testPackage % exit And the crash occurs. | |||
User Comments: |
ferrieux added on 2010-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. azaroo added on 2010-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. ferrieux added on 2010-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 ? azaroo added on 2010-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, ferrieux added on 2010-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. azaroo added on 2010-01-13 16:27:35: File Added - 358788: tclCrash858.tgz |
Attachments:
- tclCrash858.tgz [download] added by azaroo on 2010-01-13 16:27:35. [details]