Debugging tcl on Windows

I have a Tkinter application that sometimes crashes under Windows. The error is a general program that has stopped working and needs to be closed. "

After examining the event logs, I found that tcl85.dll

- this is the library responsible for the crashes.

My guess is that there is a bug in my program that misuses the tcl api and calls tcl to enter an undefined state, which ends up crashing or an error in tcl85 itself.

My question is, how can I diagnose the cause of this problem? What tools will help you get something like a backtrace where the program goes wrong? I looked at the error in the Windows event log, but the information there does not seem to be sufficient to determine the cause.

Below is the xml of the event log error:

 Name="Application Error"></Provider>
<EventID Qualifiers="0">1000</EventID>
<Level>2</Level>
<Task>100</Task>
<Keywords>0x0080000000000000</Keywords>
<TimeCreated SystemTime="2014-08-27 08:54:13"></TimeCreated>
<EventRecordID>6173</EventRecordID>
<Channel>Application</Channel>
<Computer>my.windows.8.tablet.computer</Computer>
<Security UserID=""></Security>
</System>
<EventData><Data><string>my_tkinter_app.exe</string>
<string>0.0.0.0</string>
<string>514e2c2f</string>
<string>tcl85.dll</string>
<string>8.5.2.15</string>
<string>53b1e888</string>
<string>c0000005</string>
<string>0007697f</string>
<string>1378</string>
<string>01cfc1d44828ecb0</string>
<string>C:\Users\ADMINI~1\DOWNLO~1\my_tkinter_app.exe</string>
<string>C:\Users\ADMINI~1\AppData\Local\Temp\_MEI35042\tcl85.dll</string>
<string>b7745a30-2dc7-11e4-9732-88124e8c7600</string>
<string></string>
<string></string>
</Data>
<Binary></Binary>
</EventData>
</Event>

      

From c0000005

what I understand there is an access violation, but it is still too general to determine the cause.

Unfortunately, I cannot reproduce the crash code under Linux, so I am looking for a Windows-specific way to track down this issue.

+3


source to share


2 answers


If you have a PDB file for the Tcl involved (for example, because you created it yourself), the easiest way might be to just tell Windows to safely MiniDump when the process crashes.

Windows Error Reporting System (WER) has the necessary parts to do this, you just need to set some registry keys and find the generated .dmp file.



Have a look at http://msdn.microsoft.com/en-us/library/windows/desktop/bb787181%28v=vs.85%29.aspx for the things you need:

Once you have the crash dump, you simply open it with a debugger of your choice (Visual Studio or Windbg) and start debugging, point it to your PDB files and Microsoft Symbol server, and you get a nice crash stack.

+1


source


I had an identical error on a Windows 7 desktop with Python 2.7.9 installed and it turned out to be a thread safety issue in my program. I'm not sure if your problem will be fixed with my solution, just share it.

For anyone running tkinter on a different (than main) thread, tkinter NOT THREAD SAFE . In my program, I have to run the twisted reactor on the main thread, so I run the tkinter UI on a different thread. Since I was directly calling the tkinter method (for example Text.insert()

) on the main thread, it sometimes crashes with error c0000005.

After reading this bug report , I modified my tkinter based UI module with

  • Added a command queue for a specific widget (text widget, in my case)
  • Added a handler method with after()

    and queue.get_nowait()

    as shown below:

    def commandQueueHandler(self):
        try:
            while 1:
                your_command = self.textCommandQueue.get_nowait()
                if your_command is not None:
                    # execute the command ....
                self.Text.update_idletasks()
        except Queue.Empty:
            pass
        self.Text.after(100, self.commandQueueHandler)  
    
          

    This method runs automatically every 100ms to process the queued command, but you must call it once to get it to work. (I run this in __init__

    , after all the widgets have been initialized.)



On the main thread, all I have to do is just put the command / message on the command queue and wait for it to be processed. Of course, there will be a slight delay before executing the command.

What is it! With this modification, my program fails to run tcl error c0000005 after a 2 week stress test. Hope this helps.

ps Be careful, only the widget classes provide a method after()

, check this page for more details .

+1


source







All Articles