<p>We have a Linux application that makes use of OpenSSL's Python bindings and I suspect it is causing random crashes. Occasionally, we see it crash with the message: </p>

<blockquote>
  <p>Python Fatal Error: GC Object already tracked</p>
</blockquote>

<p>which would appear to be either a programming error on the part of the library, or a symptom of memory corruption. Is there any way to know the last line of Python source code it executed, given a core file? Or if it is attached in GDB? I realize it is probably all compiled bytecode, but I'm hoping there someone out there may have dealt with this. Currently it is running with the trace module active and we're hoping it will happen again, but it could be a long while.</p>

If you have mac or sun box kicking around you could use
dtrace
and a version of python compiled with dtrace to figure out what the application was doing at the time. Note: in 10.5 python is pre-compiled with dtrace which is really nice and handy.
If that isn't available to you, then you can
import gc
and enable debugging which you can then put out to a log file.
To specifically answer your question regarding debugging with GDB you might want to read "
Debugging With GDB
" on the python wiki.