Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging tcl crash on windows

I have a Tkinter application that sometimes crashes under Windows. The error is a generic 'program has stopped working and needs to close'.

After examining the event logs, I find that tcl85.dll is the library responsible for the crash.

My guess is that there is either a bug in my program which misuses the tcl api and causes tcl to enter an undefined state, eventually resulting in a crash, or there is a bug in tcl85 itself.

My question is, how can I diagnose the cause of this problem? Which tools would help get something like a backtrace on where the program is erring? I have examined the error in the windows event log, but the information there doesn't seem sufficient for identifying a 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 the c0000005 I gather that there is an access violation, but this is still too generic to identify a cause.

Unfortunately, I am not able to reproduce the crash under Linux, so I am looking for a windows-specific way of tracing this issue.

like image 834
ealfonso Avatar asked Jul 11 '26 01:07

ealfonso


2 Answers

If you have a PDB file for the Tcl involved (e.g. because you built it yourself), the easiest way can be to simply instruct windows to safe a MiniDump when the process crashes.

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

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

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 Microsofts Symbol server and get a nice stacktrace of the crash.

like image 196
schlenk Avatar answered Jul 14 '26 08:07

schlenk


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

For all who runs tkinter in other(than main) thread, tkinter is NOT THREAD SAFE. In my program, I have to run twisted reactor in main thread, so I run tkinter UI in another thread. Since I directly called tkinter method (like Text.insert()) in main thread, it occasionally crash with c0000005 error.

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

  1. Added a command queue to specific widget (Text widget, in my case)
  2. Added a handler method with after() and queue.get_nowait() as 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 self-trigger every 100ms to handle the command in the queue, but you have to trigger it once to make it work. (I trigger this in __init__, after all widget was initialized.)

In main thread, all I have to do is just put command/message in the command queue and wait for it to be handled. Of course, there will be a little delay before the command was executed.

That's it! With this modification, my program runs no tcl c0000005 error after 2 week stress test. Hope this helps.

p.s. Be careful, only widget classes provide after() method, check this page for details.

like image 29
Jkm Avatar answered Jul 14 '26 10:07

Jkm