in reply to Debugging Threads

Well you havn't shown any code, but the error sure looks like you are trying to access Tk widgets from threads. You cannot do that. Threads can be used with Tk, but Tk is "NOT THREAD-SAFE". You have to create all threads before you use any Tk statements, and use Tk only in a single thread(normally the main thread). So if you are trying to launch a thread, from a sub, after Tk is up-and-running, the thread will have Tk code in it, even if it's code block dosn't contain Tk code.....because of the way threads are created by copying the parent.

For what it is worth, if you want to access widgets from threads, you will need to use Gtk2 or Wx(which is based on Gtk2), and use it's thread->enter and thread->leave methods. Gtk2 is working toward real thread safety, Tk is not.


I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Debugging Threads
by Ace128 (Hermit) on Dec 12, 2005 at 18:16 UTC
    Aha... Is there a way to go step by step in the code somehow?
      That is something I would like to learn myself. :-) If you have perl and Tk compiled with debugging support, and you havn't stripped them, you can run start perl under gdb, then run the Tk program, and watch for what happens. I'm only rudimentarily familiar with doing it, so you might want to google for "gdb perl Tk" or "debugging perl tk", and see what you can come up with.

      Maybe you could run it under ptkdb, and see what happens when you step thru it, but with threads( and Tk not being thread-safe), the error will be "weird" and may not follow a repeatable pattern. It will just happen seemingly at random times.


      I'm not really a human, but I play one on earth. flash japh
        Hey, Devel::ptkdb is fonky! Thanks!