public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Smart pointer wrapper for frame_info
@ 2022-04-07 23:19 Tom Tromey
  2022-04-07 23:19 ` [PATCH 1/4] Switch order of comparison in some spots Tom Tromey
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Tom Tromey @ 2022-04-07 23:19 UTC (permalink / raw)
  To: gdb-patches

GDB occasionally gets bugs where a frame_info is kept alive across a
call to reinit_frame_cache.  This causes a use-after-free and, if
you're lucky, a crash.

This series aims to make this setup more "reliable", in the sense that
you'll always get a crash if you break the rules.  This is done by
wrapping frame_info in a smart pointer class, and having
reinit_frame_cache invalidate all the pointers.

I looked into a more ambitious approach: having the frame_info
wrappers automatically "reinflate" on demand after invalidation.
However, I couldn't readily make this work.  I am not completely sure,
but I think there are a few issues.

First, sometimes reinit_frame_cache is called after other global state
has been changed.  This means that one can't call get_frame_id from
there.

Second, I think computing the frame_id requires some unwinding.  This
means that it doesn't make sense to eagerly compute the frame_id when
constructing a frame_info.

This brings up another point -- most frame_info_ptr objects will not
really be needed after a reinit.  So, saving them all is an
unnecessary expense.  But accepting this means, essentially, accepting
the status quo.

It's possible to add a "stash" method to the new smart pointer class,
to make selected instances auto-inflate.  However I haven't done so.
That may be more expensive as well, as these objects are often passed
by value in the current series; and again it doesn't seem hugely
better than the status quo.

Regression tested on x86-64 Fedora 34.

Let me know what you think.  I tend to think that at least patch #2
could go in regardless of whether the rest of this series does.

Tom



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

end of thread, other threads:[~2022-04-22 14:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 23:19 [PATCH 0/4] Smart pointer wrapper for frame_info Tom Tromey
2022-04-07 23:19 ` [PATCH 1/4] Switch order of comparison in some spots Tom Tromey
2022-04-08  0:25   ` John Baldwin
2022-04-08 17:40   ` Pedro Alves
2022-04-07 23:19 ` [PATCH 2/4] Remove frame_id_eq Tom Tromey
2022-04-08  0:27   ` John Baldwin
2022-04-07 23:19 ` [PATCH 3/4] Introduce frame_info_ptr smart pointer class Tom Tromey
2022-04-08 14:06   ` Bruno Larsen
2022-04-08 15:18     ` Tom Tromey
2022-04-08 16:45       ` Bruno Larsen
2022-04-08 15:49   ` Pedro Alves
2022-04-08 19:03     ` Tom Tromey
2022-04-08 19:22       ` Pedro Alves
2022-04-21 12:08 ` [PATCH 0/4] Smart pointer wrapper for frame_info Bruno Larsen
2022-04-22 14:58   ` Tom Tromey

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).