|
2016-10-04
| ||
| 09:00 | • Closed ticket [f23d040b9b]: application hangs in TclInitNotifier using TCL 8.5.1... artifact: fc9aae62ce user: jan.nijtmans | |
| 01:43 | • Ticket [f23d040b9b]: 4 changes artifact: 22dbae61bd user: markf78 | |
|
2016-09-26
| ||
| 14:51 | • Ticket [f23d040b9b]: 4 changes artifact: 4bcfd8a1e6 user: jan.nijtmans | |
| 11:32 | • Ticket [f23d040b9b]: 3 changes artifact: db976e9f63 user: gustafn2 | |
|
2016-08-23
| ||
| 18:45 | • Ticket [f23d040b9b]: 3 changes artifact: 00aac11cbe user: markf78 | |
| 17:40 | • Ticket [f23d040b9b]: 3 changes artifact: e67e2ef8e7 user: dgp | |
| 05:41 | • Ticket [f23d040b9b]: 3 changes artifact: ab95bee254 user: apnadkarni | |
| 02:24 | • Open ticket [f23d040b9b]. artifact: 31e9c92831 user: markf78 | |
|
2016-08-22
| ||
| 07:04 | • Closed ticket [f23d040b9b]. artifact: 3759d339e4 user: jan.nijtmans | |
|
2016-07-30
| ||
| 16:20 | • Ticket [f23d040b9b]: 3 changes artifact: 2f44b562f3 user: markf78 | |
| 16:19 | • New ticket [f23d040b9b]. artifact: 249904a7f5 user: markf78 | |
application hangs in TclInitNotifier using TCL 8.5.19 on windows
Closed / Out of Datef23d040b9b1a0894a70b5bb45632c7d5f33ccdebCreated 10 years agoUpdated 10 years ago
Descriptionplain2016-07-30 16:19:59
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.
markf78 Ticket [f23d040b9b]: 3 changes
[History diff]2016-07-30 16:20:41
jan.nijtmanswiki2016-08-22 07:04:54
Dup of [159a3e1dab1142775a8e]. See full explanation there.
markf78plain2016-08-23 02:24:28
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.
apnadkarniplain2016-08-23 05:41:42
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?
dgpplain2016-08-23 17:40:58
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?
markf78plain2016-08-23 18:45:34
@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();
}
}
gustafn2plain2016-09-26 11:32:18
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.
jan.nijtmansplain2016-09-26 14:51:35
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.
markf78plain2016-10-04 01:43:32
I'm fine with this resolution. 8.6.6 was an acceptable solution.
jan.nijtmansplain2016-10-04 09:00:58
Since this is apparently already fixed in 8.6, "Out of Date" is more appropriate.
Log in (anonymous is fine) to add a comment.