This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA 00/14] add a smart pointer for PyObject*


This patch introduces a new smart pointer that manages a Python
reference, and then changes parts of the Python layer to use this new
wrapper.

Dealing with reference counting in the Python layer has been a
consistent source of bugs.  It's relatively easy to introduce a memory
leak, especially when dealing with an error case.  This new class
simplifies typical Python-facing code, reducing the chance of such
errors.

Many spots in gdb's Python layer deal with error-handling by "goto"
with a "fail" label; this series removes many such "goto"s.  This
series provides other sorts of cleanups as well.

I avoided introducing changes when an ensure_python_env cleanup was in
use locally; throwing an exception across one of these when a
gdbpy_reference is in used could change the order of operations,
resulting in a Py_DECREF when the GIL is not held.  I'm not sure
whether this happens in practice but it seemed best not to find out.

This is a net code reduction even including the new code and the
ChangeLog entries.

In the longer run I'd like to remove make_cleanup_py_decref and
ensure_python_env.

I've built on x86-64 Fedora 24 and run the gdb.python tests locally.
I'm also currently sending this through the buildbot.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]