问题描述
我的 python 代码因错误 'GC Object already Tracked' 而崩溃.试图找出调试此崩溃的最佳方法.
My python code has been crashing with error 'GC Object already Tracked' . Trying to figure out the best approach to debug this crashes.
操作系统:Linux.
OS : Linux.
- 是否有适当的方法来调试此问题.
在下面的文章中有几个建议.使用 GDB 进行 Python 内存调试
There were couple of suggestions in the following article. Python memory debugging with GDB
不确定哪种方法对作者有效.
Not sure which approach worked for the author.
- 有没有办法在这种情况下生成可以分析的内存转储.就像在 Windows 世界中一样.
找到了一些关于此的文章.但不能完全回答我的问题:http://pfigue.github.io/blog/2012/12/28/where-is-my-core-dump-archlinux/
Found some article on this. But not entirely answers my question: http://pfigue.github.io/blog/2012/12/28/where-is-my-core-dump-archlinux/
推荐答案
在我的场景中找到了这个问题的原因(不一定是GC对象崩溃的唯一原因).我使用 GDB 和核心转储来调试这个问题.
Found out the reason for this issue in my scenario (not necessarily the only reason for the GC object crash). I used the GDB and Core dumps to debug this issue.
我有 Python 和 C 扩展代码(在共享对象中).Python 代码使用 C 扩展代码注册回调例程.在某个工作流中,来自 C 扩展代码的线程正在调用 Python 代码中注册的回调例程.
I have Python and C Extension Code (in shared object). Python code registers a Callback routine with C Extension code. In a certain workflow a thread from C Extension code was calling the registered Call back routine in Python code.
这通常工作得很好,但是当多个线程同时执行相同的操作时,它会导致崩溃并显示GC 对象已被跟踪".
This usually worked fine but when multiple threads did the same action concurrently it resulted in the Crash with 'GC Object already tracked'.
同步多个线程对 python 对象的访问确实解决了这个问题.
Synchronizing the access to python objects for multiple thread does resolve this issue.
感谢任何对此的回应.
这篇关于调试 Python 致命错误:已跟踪 GC 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!