Menu

Debug Exception - dictionary changed size dur

mkoenig
2011-06-06
2013-03-15
  • mkoenig

    mkoenig - 2011-06-06

    We are having a problem debugging our application using the pydev debugger. We have a application that creates and destroy threads and when a break point is set in the main thread we occasionally get the following exception

      File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 102, in trace_dispatch
        self.doWaitSuspend(thread, frame, event, arg)
      File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd_frame.py", line 25, in doWaitSuspend
        self._args.doWaitSuspend(*args, **kwargs)
      File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 687, in doWaitSuspend
        self.processInternalCommands()
      File "C:\eclipse\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\pydevd.py", line 399, in processInternalCommands
        for tId in self.RUNNING_THREAD_IDS.keys():
    RuntimeError: dictionary changed size during iteration

    From the code I am assuming this is being caused by one of our background threads being destroyed changing the self.RUNNING_THREAD_IDS to change.

    Has anyone else ran into this? If this is a bug in the debbuger code does anyone know the issue so I can monitor it.? And last is there a recommend work around/code change for this.

    Thanks

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-06-06

    What's your Python version?

    Cheers,

    Fabio

     
  • Darrell

    Darrell - 2011-06-23

    I encounter this too with my version is  " PyDev for Eclipse 2.1.0.2011052613" running on Ubuntu.

    If you look in this version at pydevd.py on line 404, you have:

                for tId in self.RUNNING_THREAD_IDS.keys():
                    try:
                        if not DictContains(foundThreads, tId):
                            self.processThreadNotAlive(tId)
                    except:
                        sys.stderr.write('Error iterating through %s (%s) - %s\n' % (foundThreads, foundThreads.__class__, dir(foundThreads)))
                        raise

    processThreadNotAlive is the method that modifies RUNNING_THREAD_IDS.

    They need to fix this by either making a copy of that list and iterate over that, or make a list of thread id's that we want to delete, and delete them after this loop iteration.
    You can't change this list while iterating over it.

    I'm going to patch it tonight and test it.

     
  • Darrell

    Darrell - 2011-06-29

    This patch seemed to work for me…

    -- pydevd.py.old 2011-06-29 10:15:43.463040992 -0400
    +++ pydevd.py 2011-06-29 10:13:00.154231186 -0400
    @@ -52,6 +52,7 @@
    import pydevd_io
    from pydevd_additional_thread_info import PyDBAdditionalThreadInfo
    import time
    +import copy
    threadingEnumerate = threading.enumerate
    threadingCurrentThread = threading.currentThread

    @@ -400,7 +401,8 @@
                         if hasattr(t, 'doKill'):
                             t.doKill()
                
    -            for tId in self.RUNNING_THREAD_IDS.keys():
    +            runningThreadsCopy = copy.copy(self.RUNNING_THREAD_IDS)
    +            for tId in runningThreadsCopy.keys():
                     try:
                         if not DictContains(foundThreads, tId):
                             self.processThreadNotAlive(tId)

    cheers,
    Darrell.

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-06-29

    I'm sorry I didn't answer on this thread, but this should be already fixed for PyDev 2.2 (see release notes at: http://pydev.org/)

    Cheers,

    Fabio

    p.s.: If the current release doesn't work for you, please let me know.

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.