Hello list,
from some time I receive a seg fault message exiting my app, and like now
I'm trying to debug it, so I install a python-dbg, wx-dbg and all the
other stuff for use it with gdb.
After some tries, gdb reply the message "Fatal Python error:
PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
Thanks,
Michele
The backtrace are:
Fatal Python error: PyThreadState_Get: no current thread
Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb7da58c0 (LWP 32702)]
0xb7f67424 in __kernel_vsyscall ()
(gdb) backtrace #0 0xb7f67424 in __kernel_vsyscall () #1 0xb7dd1640 in raise () from /lib/i686/cmov/libc.so.6 #2 0xb7dd3018 in abort () from /lib/i686/cmov/libc.so.6 #3 0x08114d93 in Py_FatalError (msg=0x8175d18 "PyThreadState_Get: no current thread") at ../Python/pythonrun.c:1561 #4 0x08110ecd in PyThreadState_Get () at ../Python/pystate.c:296 #5 0x080fe23b in PyErr_Fetch (p_type=0xbfb80328, p_value=0xbfb80324, p_traceback=0xbfb80320) at ../Python/errors.c:217 #6 0x080beb4e in slot_tp_del (self=0x9bcb3b4) at ../Objects/typeobject.c:5004 #7 0x080b046f in subtype_dealloc (self=0x9bcb3b4) at ../Objects/typeobject.c:664 #8 0x08096a70 in _Py_Dealloc (op=0x9bcb3b4) at ../Objects/object.c:1938 #9 0xb782317a in ~wxPyEvtSelfRef (this=0x9e23454) at src/helpers.cpp:1948 #10 0xb78263b3 in ~wxPyEvent (this=0x9e23430) at src/helpers.cpp:1987 #11 0xb6f73bc8 in wxObjectListNode::DeleteData (this=0x9c09b58) at ../src/common/list.cpp:585 #12 0xb6f73d40 in wxListBase::DoDeleteNode (this=0x9d46fe8, node=0x9c09b58) at ../src/common/list.cpp:372 #13 0xb6f74201 in ~wxListBase (this=0x9d46fe8) at ../src/common/list.cpp:212 #14 0xb6f755ed in ~wxList (this=0x9d46fe8) at ../include/wx/list.h:1185 #15 0xb6fddb59 in ~wxEvtHandler (this=0x98439d8) at ../src/common/event.cpp:1080 #16 0xb6f20367 in ~wxAppConsole (this=0x98439d8) at ../src/common/appbase.cpp:143 #17 0xb72826b8 in ~wxAppBase (this=0x98439d8) at ../src/common/appcmn.cpp:133 #18 0xb71bfdef in ~wxApp (this=0x98439d8) at ../src/gtk/app.cpp:346 #19 0xb7825ff3 in ~wxPyApp (this=0x98439d8) at src/helpers.cpp:137 #20 0xb788a9a5 in _wrap_delete_PyApp (args=0x992e8c8) at src/gtk/_core_wrap.cpp:31211 #21 0xb7831a23 in PySwigObject_dealloc (v=0x992e8c8) at src/gtk/_core_wrap.cpp:1443 #22 0x08096a70 in _Py_Dealloc (op=0x992e8c8) at ../Objects/object.c:1938 #23 0x0808dfdc in dict_dealloc (mp=0x9bc9534) at ../Objects/dictobject.c:851 #24 0x08096a70 in _Py_Dealloc (op=0x9bc9534) at ../Objects/object.c:1938 #25 0x080b0629 in subtype_dealloc (self=0x9bcb114) at ../Objects/typeobject.c:697 #26 0x08096a70 in _Py_Dealloc (op=0x9bcb114) at ../Objects/object.c:1938 #27 0x0808cf6c in insertdict (mp=0xb7d5d5d4, key=0xb7d61648, hash=-1582925558, value=0x8189888) at ../Objects/dictobject.c:416 #28 0x0808d77c in PyDict_SetItem (op=0xb7d5d5d4, key=0xb7d61648, value=0x8189888) at ../Objects/dictobject.c:641 #29 0x080924ec in _PyModule_Clear (m=0xb7d65814) at ../Objects/moduleobject.c:136 #30 0x08104845 in PyImport_Cleanup () at ../Python/import.c:474 #31 0x08111ee7 in Py_Finalize () at ../Python/pythonrun.c:399 #32 0x08059d4b in Py_Main (argc=1, argv=0xbfb80964) at ../Modules/main.c:554 #33 0x08058d16 in main (argc=Cannot access memory at address 0x7fbe
) at ../Modules/python.c:23
Hello list,
from some time I receive a seg fault message exiting my app, and like now
I'm trying to debug it, so I install a python-dbg, wx-dbg and all the
other stuff for use it with gdb.
After some tries, gdb reply the message "Fatal Python error:
PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
It's probably yours as wxPython works with threads as long as you don't make any direct calls to wx in your threads. You have to use one of the threadsafe wx methods to communicate with your GUI. If you don't, then your application will crash or exhibit weird behavior. I can't tell from this traceback if that is what you did or not.
Also try Google. I looked up "Fatal Python error: PyThreadState_Get: no current thread" and there's quite a few hits, but since you didn't include any code, I have no idea which link is relevant. You'll have to check it out yourself.
···
Thanks,
Michele
The backtrace are:
Fatal Python error: PyThreadState_Get: no current thread
Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb7da58c0 (LWP 32702)]
0xb7f67424 in __kernel_vsyscall ()
(gdb) backtrace #0 0xb7f67424 in __kernel_vsyscall () #1 0xb7dd1640 in raise () from /lib/i686/cmov/libc.so.6 #2 0xb7dd3018 in abort () from /lib/i686/cmov/libc.so.6 #3 0x08114d93 in Py_FatalError (msg=0x8175d18 "PyThreadState_Get: no current thread") at ../Python/pythonrun.c:1561 #4 0x08110ecd in PyThreadState_Get () at ../Python/pystate.c:296 #5 0x080fe23b in PyErr_Fetch (p_type=0xbfb80328, p_value=0xbfb80324, p_traceback=0xbfb80320) at ../Python/errors.c:217 #6 0x080beb4e in slot_tp_del (self=0x9bcb3b4) at ../Objects/typeobject.c:5004 #7 0x080b046f in subtype_dealloc (self=0x9bcb3b4) at ../Objects/typeobject.c:664 #8 0x08096a70 in _Py_Dealloc (op=0x9bcb3b4) at ../Objects/object.c:1938 #9 0xb782317a in ~wxPyEvtSelfRef (this=0x9e23454) at src/helpers.cpp:1948 #10 0xb78263b3 in ~wxPyEvent (this=0x9e23430) at src/helpers.cpp:1987 #11 0xb6f73bc8 in wxObjectListNode::DeleteData (this=0x9c09b58) at ../src/common/list.cpp:585 #12 0xb6f73d40 in wxListBase::DoDeleteNode (this=0x9d46fe8, node=0x9c09b58) at ../src/common/list.cpp:372 #13 0xb6f74201 in ~wxListBase (this=0x9d46fe8) at ../src/common/list.cpp:212 #14 0xb6f755ed in ~wxList (this=0x9d46fe8) at ../include/wx/list.h:1185 #15 0xb6fddb59 in ~wxEvtHandler (this=0x98439d8) at ../src/common/event.cpp:1080 #16 0xb6f20367 in ~wxAppConsole (this=0x98439d8) at ../src/common/appbase.cpp:143 #17 0xb72826b8 in ~wxAppBase (this=0x98439d8) at ../src/common/appcmn.cpp:133 #18 0xb71bfdef in ~wxApp (this=0x98439d8) at ../src/gtk/app.cpp:346 #19 0xb7825ff3 in ~wxPyApp (this=0x98439d8) at src/helpers.cpp:137 #20 0xb788a9a5 in _wrap_delete_PyApp (args=0x992e8c8) at src/gtk/_core_wrap.cpp:31211 #21 0xb7831a23 in PySwigObject_dealloc (v=0x992e8c8) at src/gtk/_core_wrap.cpp:1443 #22 0x08096a70 in _Py_Dealloc (op=0x992e8c8) at ../Objects/object.c:1938 #23 0x0808dfdc in dict_dealloc (mp=0x9bc9534) at ../Objects/dictobject.c:851 #24 0x08096a70 in _Py_Dealloc (op=0x9bc9534) at ../Objects/object.c:1938 #25 0x080b0629 in subtype_dealloc (self=0x9bcb114) at ../Objects/typeobject.c:697 #26 0x08096a70 in _Py_Dealloc (op=0x9bcb114) at ../Objects/object.c:1938 #27 0x0808cf6c in insertdict (mp=0xb7d5d5d4, key=0xb7d61648, hash=-1582925558, value=0x8189888) at ../Objects/dictobject.c:416 #28 0x0808d77c in PyDict_SetItem (op=0xb7d5d5d4, key=0xb7d61648, value=0x8189888) at ../Objects/dictobject.c:641 #29 0x080924ec in _PyModule_Clear (m=0xb7d65814) at ../Objects/moduleobject.c:136 #30 0x08104845 in PyImport_Cleanup () at ../Python/import.c:474 #31 0x08111ee7 in Py_Finalize () at ../Python/pythonrun.c:399 #32 0x08059d4b in Py_Main (argc=1, argv=0xbfb80964) at ../Modules/main.c:554 #33 0x08058d16 in main (argc=Cannot access memory at address 0x7fbe
) at ../Modules/python.c:23
After some tries, gdb reply the message "Fatal Python error: PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
Hi Mike,
It's probably yours as wxPython works with threads as long as you don't make any direct calls to wx in your threads. You have to use one of the threadsafe wx methods to communicate with your GUI.
Like now I use, as far as I know, those methods for communicate with wx gui
If you don't, then your application will crash or exhibit weird behavior. I can't tell from this traceback if that is what you did or
not.
So you are saying that can be that the problem?
Do you know if there is something other debug option / code for see
where the segfault are generated?
Also try Google. I looked up "Fatal Python error: PyThreadState_Get:
no current thread" and there's quite a few hits,
After some tries, gdb reply the message "Fatal Python error: PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
Hi Mike,
It's probably yours as wxPython works with threads as long as you don't make any direct calls to wx in your threads. You have to use one of the threadsafe wx methods to communicate with your GUI.
Like now I use, as far as I know, those methods for communicate with wx gui
If you don't, then your application will crash or exhibit weird behavior. I can't tell from this traceback if that is what you did or
not.
So you are saying that can be that the problem?
Do you know if there is something other debug option / code for see
where the segfault are generated?
Also try Google. I looked up "Fatal Python error: PyThreadState_Get:
no current thread" and there's quite a few hits,
but since you didn't include any code, I have no idea which link is relevant. You'll have to check it out yourself.
The problem it's that I have a complex project that I can't publish and
I'm looking only for a tip for better debug the problem.
Thanks,
Michele
Hopefully someone with more experience in debugging segfaults will jump in here, but I think one of the ways I've seen mentioned on here is to use the Python debugger. Here's a link to the docs: pdb — The Python Debugger — Python 3.13.0 documentation
And here are a few other links for other python debuggers (or just more info):
You might try adding in breakpoints to your code until you find the spot where it crashes...although if your program segfaults just in normal use, that won't work. You could also cross-post to comp.lang.python on google groups and see if anyone there has a clue.
Hello list,
from some time I receive a seg fault message exiting my app, and like now
I'm trying to debug it, so I install a python-dbg, wx-dbg and all the
other stuff for use it with gdb.
After some tries, gdb reply the message "Fatal Python error:
PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
How are you terminating the app? Naturally as the last top-level window is closed or are you forcing it somehow? I'll assume in the rest of this message that it is a natural shutdown.
From the backtrace it appears to me that there are still pending events for some window when it is being destroyed and one of those events is a custom event derived from wx.PyEvent or wx.PyCommandEvent. When one of those is destroyed it tries to acquire the Python GIL in order to safely be able to DECREF the Python part of the object. But since Python is in the process of shutting down it is not able to do that and Python aborts with the threadstate error.
I will add a conditional to help avoid this problem, but you can probably do some things in your app a little cleaner to work around it too. Normally top-level windows will not be destroyed (and therefore the app closed and MainLoop exited when the last frame is gone) if there are still pending events. So I assume that the event in question in this case is coming from your worker threads *after* the gui thread has already processed the pending events and decided that it is time to exit and cleanup. So if you can shutdown your threads before that happens, or at least prevent them from sending more events, then you should avoid the problem.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
The problem it's that I have a complex project that I can't publish and
I'm looking only for a tip for better debug the problem.
In situations like this the best thing is usually to progressively disable parts of the application until the problem goes away, and then to selectively enable parts again until you are able to narrow down the exact cause of the problem. Then once you understand the cause you can either devise a fix, or a workaround, or reimplement the problem in a small sample app that you can send to us for advice.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Hello list, from some time I receive a seg fault message exiting my
app, and like now I'm trying to debug it, so I install a python-dbg, wx-dbg and all the other stuff for use it with gdb. After some tries, gdb reply the message "Fatal Python error: PyThreadState_Get: no current thread"
My app use a lot of threads into its work.
Python 2.5 and wx-the-last
Can be mine or a wx problem?
How are you terminating the app? Naturally as the last top-level window is closed or are you forcing it somehow? I'll assume in the rest of this message that it is a natural shutdown.
First of all, thanks for both replies.
Into my code, I "simulate" a wx.FutureCall with a thread that propagate
the call through a wx.PostEvent.
I found that I say to the app to exit (wx.Exit) and
_after_ I call a PostEvent