Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Python Fatal Error: 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.

OS : Linux.

  • Is there a proper way to debug this issue.

There were couple of suggestions in the following article. Python memory debugging with GDB

Not sure which approach worked for the author.

  • Is there a way to generate memory dumps in such scenario which could be analyzed. Like in Windows world.

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/

like image 382
Feru Avatar asked Apr 20 '14 05:04

Feru


1 Answers

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.

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.

This usually worked fine but when multiple threads did the same action concurrently it resulted in the Crash with 'GC Object already tracked'.

Synchronizing the access to python objects for multiple thread does resolve this issue.

Thanks to any responded to this.

like image 76
Feru Avatar answered Oct 31 '22 13:10

Feru