Artifacts Associated With Ticket f23d040b9b1a0894
Ticket change [249904a7f5] (rid 148294) by markf78 on 2016-07-30 16:19:59:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I am seeing an intermittent issue in void TclInitNotifier(void) where execution is stuck in the following loop: for (tsdPtr = firstNotifierPtr; tsdPtr && tsdPtr->threadId != threadId; tsdPtr = tsdPtr->nextPtr) { /* Empty loop body. */ } Here's pseudocode that illustrates how to reproduce the problem: for (i=1 to N) { Tcl_CreateInterp Tcl_SetVar(m_interp, "tcl_library", m_tclLibrary, 0); Tcl_Init approx 100 Tcl_SetVar commands (different variable names) Tcl_EvalFile Tcl_DeleteInterp } for some number N between 1-7 Stack trace: tcl85g.dll!TclInitNotifier() Line 120 tcl85g.dll!TclInitSubsystems() Line 982 tcl85g.dll!Tcl_CreateInterp() Line 408 My build parameters: cd win nmake -f makefile.vc OPTS=msvcrt MSVCDIR=IDE TMP_DIR=$(Platform)\$(Configuration) OUT_DIR=$(Platform)\$(Configuration) Let me know what other information is needed to help resolve this problem. Thank you very much. - foundin initialized to: "8.5.19"
- is_private initialized to: "0"
- login: "markf78"
- priority initialized to: "5 Medium"
- private_contact initialized to: "c0c4e0a1572c9da806bf9406bd1f834de289c187"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "markf78"
- subsystem initialized to: "20. [interp]"
- title initialized to: "bug in TclInitNotifier using TCL 8.5.19 on windows"
- type initialized to: "Bug"
Ticket change [2f44b562f3] (rid 148295) by markf78 on 2016-07-30 16:20:41:
- login: "markf78"
- mimetype: "text/plain"
- title changed to:
application hangs in TclInitNotifier using TCL 8.5.19 on windows
Ticket change [3759d339e4] (rid 148410) by jan.nijtmans on 2016-08-22 07:04:54:
- assignee changed to: "jan.nijtmans"
- closedate changed to: "2457622.79508053"
- closer changed to: "jan.nijtmans"
- icomment:
Dup of [159a3e1dab1142775a8e]. See full explanation there.
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Duplicate"
- status changed to: "Closed"
Ticket change [31e9c92831] (rid 148428) by markf78 on 2016-08-23 02:24:28:
- closer changed to: "nobody"
- icomment:
Changed my build parameters to: nmake -f makefile.vc OPTS=msvcrt,threads MSVCDIR=IDE TMP_DIR=$(Platform)\$(Configuration) OUT_DIR=$(Platform)\$(Configuration) This generates a file called tcl85t.dll. Using that dll and the problem still exists: Stack: tcl85tg.dll!TclInitNotifier() Line 118 + 0x1f bytes C tcl85tg.dll!TclInitSubsystems() Line 982 C tcl85tg.dll!Tcl_CreateInterp() Line 408 C Reopening ticket. Please let me know what information you need to get this problem resolved.
- login: "markf78"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
Ticket change [ab95bee254] (rid 148429) by apnadkarni on 2016-08-23 05:41:42:
- icomment:
Sorry, no direct answer but just to get make sure there are no build configuration issues... The flags that you show indicate a non-debug build. Yet the Stack dump shows a debug build (tcl85tg with "g" indicating debug). Something seems off there. afaik mixing the release and debug C runtimes will lead to all kinds of issues. Could you double check that the right DLL is being loaded? Also, given you seem to have your own main program and not using tclsh, are you calling Tcl_FindExecutable ? Probably a red herring too but that is another common mistake though I doubt it would lead to this symptom. Finally, is it possible for you to try 8.6.6 to see if the same problem exists?
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [e67e2ef8e7] (rid 148448) by dgp on 2016-08-23 17:40:58:
- icomment:
TclInitSubsystems() is in the stack trace, so unlikely to be any FindExecutable - related problem. How can the program possibly hang in that loop? firstNotifierPtr points to a finite list. When the list is fully scanned, the loop terminates. Is the list corrupted somehow? What's the evidence?
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [00aac11cbe] (rid 148449) by markf78 on 2016-08-23 18:45:34:
- icomment:
@apnadkarni Sorry my previous comment was confusing. Test 1. Using the tcl85t.dll and I was able to reproduce the deadlock. Test 2. I then rebuild using debug symbols (so using the tcl85tg.dll) and again I reproduced the deadlock. In Visual Studio, i pushed pause to view the system stack and it was again stuck in the same loop which I provided earlier. Using this puase technique consistently yields the same result. Test 3. Upgraded the tcl source code to TCL 8.6.6. Built using: nmake -f makefile.vc OPTS=msvcrt MSVCDIR=IDE TMP_DIR=$(Platform)\$(Configuration) OUT_DIR=$(Platform)\$(Configuration) So far, I cannot reproduce the problem. I will have our internal QA team continue to attempt to reproduce and I will then report my findings here. Notes. 1. I'm not using Tcl_FindExecutable. 2. Here's my C# wrapper to the native tcl code: using System; using System.Runtime.InteropServices; namespace MyNamespace { public class TCL { #if DEBUG const string tcldll = "tcl85tg.DLL"; #else const string tcldll = "tcl85t.DLL"; #endif [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr Tcl_CreateInterp(); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern int Tcl_Init(IntPtr interp); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr Tcl_GetObjResult(IntPtr interp); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr Tcl_GetStringFromObj(IntPtr tclObj, IntPtr length); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr Tcl_SetVar(IntPtr interp, string varName, string newValue, int flags); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern int Tcl_EvalFile(IntPtr interp, string filename); [DllImport(tcldll, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] private static extern IntPtr Tcl_DeleteInterp(IntPtr interp); private IntPtr m_interp; private string m_tclLibrary; const int TCL_OK = 0; const int TCL_ERROR = 1; private string GetErrorMessage() { IntPtr obj = Tcl_GetObjResult(m_interp); if (obj == IntPtr.Zero) { return string.Empty; } else { IntPtr ptr = Tcl_GetStringFromObj(obj, IntPtr.Zero); return Marshal.PtrToStringAnsi(ptr); } } public TCL(string pathToTCL) { m_tclLibrary = pathToTCL; m_interp = Tcl_CreateInterp(); if (m_interp == IntPtr.Zero) { throw new SystemException("Can not initialize Tcl interpreter"); } } public bool InitInterpreter(out string errmsg) { errmsg = string.Empty; // set the location of the init.tcl file SetVar("tcl_library", m_tclLibrary); // attempt to init tcl i.e. evaluate the init.tcl script int result = Tcl_Init(m_interp); errmsg = (result == TCL_ERROR) ? GetErrorMessage() : string.Empty; return result == TCL_OK; } public void DeleteInterpreter() { m_interp = Tcl_DeleteInterp(m_interp); } public IntPtr SetVar(string varName, string newValue) { return Tcl_SetVar(m_interp, varName, newValue, 0); } public bool EvalFile(string filename, out string errmsg) { int result = Tcl_EvalFile(m_interp, filename); errmsg = (result == TCL_ERROR) ? GetErrorMessage() : string.Empty; return result == TCL_OK; } } } 3. My application code is essentially: void functionCalledOften(string pathToTcl) { TCL tcl = new TCL(pathToTcl); bool tclResult = tcl.InitInterpreter(out errmsg); if (tclResult) { // lots of tcl.SetVar's SetTclVariables(tcl, OutputFile); tclResult = tcl.EvalFile(CtrlTcl, out errmsg); if (tclResult) errmsg = string.Empty; tcl.DeleteInterpreter(); } } - login: "markf78"
- mimetype: "text/plain"
- icomment:
Ticket change [db976e9f63] (rid 148881) by gustafn2 on 2016-09-26 11:32:18:
- icomment:
It could be possible that data from already terminated threads is causing harm. Note that threaded applications have to call Tcl_FinalizeThread() on thread exit. Tcl_FinalizeThread() invokes (among other things) TclFinalizeNotifier() to clean up per-thread notifier informations.
- login: "gustafn2"
- mimetype: "text/plain"
- icomment:
Ticket change [4bcfd8a1e6] (rid 148885) by jan.nijtmans on 2016-09-26 14:51:35:
- icomment:
Waiting for markf78's feedback. If Tcl 8.6 works fine, then I'm not sure it's worth to spend too much effort on fixing this for Tcl 8.5. So I'm inclined to "Won't Fix" this. If Tcl 8.6 has the same problem, then it's another story.
- login: "jan.nijtmans"
- mimetype: "text/plain"
- severity changed to: "Important"
- icomment:
Ticket change [22dbae61bd] (rid 149025) by markf78 on 2016-10-04 01:43:32:
- icomment:
I'm fine with this resolution. 8.6.6 was an acceptable solution.
- login: "markf78"
- mimetype: "text/plain"
- username: "markf78"
- icomment:
Ticket change [fc9aae62ce] (rid 149026) by jan.nijtmans on 2016-10-04 09:00:58:
- closedate changed to: "2457665.8756813"
- closer changed to: "jan.nijtmans"
- icomment:
Since this is apparently already fixed in 8.6, "Out of Date" is more appropriate.
- login: "jan.nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Out of Date"
- status changed to: "Closed"