public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Disallow the return of borrowed references
@ 2018-09-13  5:30 Tom Tromey
  2018-09-13  5:30 ` [PATCH 1/4] Change pspace_to_pspace_object to return a new reference Tom Tromey
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Tom Tromey @ 2018-09-13  5:30 UTC (permalink / raw)
  To: gdb-patches

While working on a different Python patch, I misread
pspace_to_pspace_object and thought it was not handling reference
counts properly.

It is -- but I found it difficult to reason about because it returns a
borrowed reference, but uses gdbpy_ref as well.

This series changes gdb so that none of the Python functions will
return a borrowed reference.  These functions are modified instead to
return a new reference using gdbpy_ref<>, which not only makes the
intent clear, but also makes it more difficult to have a buggy caller.

This could go further and make all functions return gdbpy_ref<>.
(Even Python-facing ones could be done via template fuction wrappers.)
However I have not done this.

I think now gdb should disallow Python functions returning borrowed
references.  Accepting a borrowed reference is still ok, and I think
should continue to be.

I think this series found at least one bug:
infpy_thread_from_thread_handle could return None without incref'ing
it.

Let me know what you think.  I tested this on x86-64 Fedora 28.

Tom


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-09-17  5:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-13  5:30 [PATCH 0/4] Disallow the return of borrowed references Tom Tromey
2018-09-13  5:30 ` [PATCH 1/4] Change pspace_to_pspace_object to return a new reference Tom Tromey
2018-09-16  0:57   ` Simon Marchi
2018-09-16 12:59     ` Tom Tromey
2018-09-16  1:19   ` Simon Marchi
2018-09-16  1:58     ` Simon Marchi
2018-09-16 13:01       ` Tom Tromey
2018-09-13  5:30 ` [PATCH 4/4] Remove CPYCHECKER_RETURNS_BORROWED_REF Tom Tromey
2018-09-13  5:30 ` [PATCH 2/4] Change objfile_to_objfile_object to return a new reference Tom Tromey
2018-09-16  1:28   ` Simon Marchi
2018-09-16  2:00     ` Simon Marchi
2018-09-13  5:30 ` [PATCH 3/4] Change thread_to_thread_object " Tom Tromey
2018-09-16  2:11   ` Simon Marchi
2018-09-16 13:32     ` Tom Tromey
2018-09-16 14:05     ` Tom Tromey
2018-09-16 15:35       ` Tom Tromey
2018-09-17  0:52       ` Simon Marchi
2018-09-17  5:31         ` Tom Tromey
2018-09-16  0:56 ` [PATCH 0/4] Disallow the return of borrowed references Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).