Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 0/5] Smart pointer wrapper for frame_info
Date: Mon, 25 Jul 2022 14:06:32 -0300	[thread overview]
Message-ID: <20220725170637.79699-1-blarsen@redhat.com> (raw)

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.

Tromey's original plan was that these pointers could be automatically
reinflated after being invalidated, but most uses of the class would not
need to be reinflated, and setting everything up to be reinflatable
would be quite expensive, as calculating a frame_id requires some
unwinding.

I added a prepare_reinflate method, which stashes the relevant frame_id
and allows the pointer to be reinflated. However, reinflation is done
manually for now because doing it when reinit_frame_cache was creating
weird problems.

Version 2 had some problematic squashing of commits, and I tried to add
some unit tests, but those didn't work out, so I eventually dropped
that.

Bruno Larsen (2):
  Continue making GDB use frame_info_ptr
  gdb/frame: Add reinflation method for frame_info_ptr

Tom Tromey (3):
  Remove frame_id_eq
  Introduce frame_info_ptr smart pointer class
  Change GDB to use frame_info_ptr

 gdb/aarch64-fbsd-tdep.c                       |   2 +-
 gdb/aarch64-linux-tdep.c                      |   2 +-
 gdb/aarch64-tdep.c                            |  34 +-
 gdb/ada-lang.c                                |  10 +-
 gdb/ada-lang.h                                |   4 +-
 gdb/alpha-linux-tdep.c                        |   2 +-
 gdb/alpha-mdebug-tdep.c                       |  16 +-
 gdb/alpha-netbsd-tdep.c                       |   2 +-
 gdb/alpha-obsd-tdep.c                         |   2 +-
 gdb/alpha-tdep.c                              |  22 +-
 gdb/alpha-tdep.h                              |   2 +-
 gdb/amd64-darwin-tdep.c                       |   2 +-
 gdb/amd64-fbsd-tdep.c                         |   2 +-
 gdb/amd64-linux-tdep.c                        |   6 +-
 gdb/amd64-netbsd-tdep.c                       |   4 +-
 gdb/amd64-obsd-tdep.c                         |  12 +-
 gdb/amd64-sol2-tdep.c                         |   2 +-
 gdb/amd64-tdep.c                              |  34 +-
 gdb/amd64-tdep.h                              |   2 +-
 gdb/amd64-windows-tdep.c                      |  12 +-
 gdb/arc-linux-tdep.c                          |   4 +-
 gdb/arc-tdep.c                                |  20 +-
 gdb/arc-tdep.h                                |   4 +-
 gdb/arch-utils.c                              |   6 +-
 gdb/arch-utils.h                              |   8 +-
 gdb/arm-fbsd-tdep.c                           |   2 +-
 gdb/arm-linux-tdep.c                          |  14 +-
 gdb/arm-obsd-tdep.c                           |   2 +-
 gdb/arm-tdep.c                                |  62 ++--
 gdb/arm-tdep.h                                |   4 +-
 gdb/arm-wince-tdep.c                          |   2 +-
 gdb/avr-tdep.c                                |  14 +-
 gdb/ax-gdb.c                                  |   2 +-
 gdb/bfin-linux-tdep.c                         |   2 +-
 gdb/bfin-tdep.c                               |  12 +-
 gdb/blockframe.c                              |   8 +-
 gdb/bpf-tdep.c                                |   8 +-
 gdb/break-catch-throw.c                       |   2 +-
 gdb/breakpoint.c                              |  20 +-
 gdb/c-lang.c                                  |   2 +-
 gdb/cli/cli-cmds.c                            |   2 +-
 gdb/compile/compile-c-symbols.c               |   2 +-
 gdb/compile/compile-cplus-symbols.c           |   2 +-
 gdb/compile/compile-loc2c.c                   |   2 +-
 gdb/cp-abi.c                                  |   2 +-
 gdb/cp-abi.h                                  |   6 +-
 gdb/cris-tdep.c                               |  36 +-
 gdb/csky-linux-tdep.c                         |   2 +-
 gdb/csky-tdep.c                               |  22 +-
 gdb/defs.h                                    |   2 +-
 gdb/dtrace-probe.c                            |   4 +-
 gdb/dummy-frame.c                             |  12 +-
 gdb/dummy-frame.h                             |   2 +-
 gdb/dwarf2/expr.c                             |  20 +-
 gdb/dwarf2/expr.h                             |   6 +-
 gdb/dwarf2/frame-tailcall.c                   |  41 +--
 gdb/dwarf2/frame-tailcall.h                   |   6 +-
 gdb/dwarf2/frame.c                            |  37 +-
 gdb/dwarf2/frame.h                            |  12 +-
 gdb/dwarf2/loc.c                              |  38 +--
 gdb/dwarf2/loc.h                              |   8 +-
 gdb/elfread.c                                 |   4 +-
 gdb/eval.c                                    |   2 +-
 gdb/extension-priv.h                          |   2 +-
 gdb/extension.c                               |   2 +-
 gdb/extension.h                               |   4 +-
 gdb/f-valprint.c                              |   2 +-
 gdb/findvar.c                                 |  26 +-
 gdb/frame-base.c                              |   8 +-
 gdb/frame-base.h                              |  12 +-
 gdb/frame-id.h                                | 135 ++++++++
 gdb/frame-info.h                              | 208 +++++++++++
 gdb/frame-unwind.c                            |  26 +-
 gdb/frame-unwind.h                            |  36 +-
 gdb/frame.c                                   | 323 +++++++++---------
 gdb/frame.h                                   | 278 +++++----------
 gdb/frv-linux-tdep.c                          |  10 +-
 gdb/frv-tdep.c                                |  10 +-
 gdb/ft32-tdep.c                               |   8 +-
 gdb/gcore.c                                   |   2 +-
 gdb/gdbarch-components.py                     |  30 +-
 gdb/gdbarch-gen.h                             |  60 ++--
 gdb/gdbarch-selftests.c                       |   2 +-
 gdb/gdbarch.c                                 |  30 +-
 gdb/gdbtypes.h                                |   5 +-
 gdb/gnu-v3-abi.c                              |   2 +-
 gdb/guile/guile-internal.h                    |   4 +-
 gdb/guile/scm-frame.c                         |  48 +--
 gdb/guile/scm-symbol.c                        |   4 +-
 gdb/h8300-tdep.c                              |  12 +-
 gdb/hppa-bsd-tdep.c                           |   2 +-
 gdb/hppa-linux-tdep.c                         |   8 +-
 gdb/hppa-netbsd-tdep.c                        |   4 +-
 gdb/hppa-tdep.c                               |  32 +-
 gdb/hppa-tdep.h                               |   8 +-
 gdb/i386-bsd-tdep.c                           |   2 +-
 gdb/i386-darwin-tdep.c                        |   4 +-
 gdb/i386-darwin-tdep.h                        |   2 +-
 gdb/i386-fbsd-tdep.c                          |   2 +-
 gdb/i386-gnu-tdep.c                           |   6 +-
 gdb/i386-linux-tdep.c                         |  10 +-
 gdb/i386-netbsd-tdep.c                        |   4 +-
 gdb/i386-nto-tdep.c                           |   4 +-
 gdb/i386-obsd-tdep.c                          |  10 +-
 gdb/i386-sol2-tdep.c                          |   2 +-
 gdb/i386-tdep.c                               |  54 +--
 gdb/i386-tdep.h                               |  10 +-
 gdb/i386-windows-tdep.c                       |   2 +-
 gdb/i387-tdep.c                               |   6 +-
 gdb/i387-tdep.h                               |   8 +-
 gdb/ia64-libunwind-tdep.c                     |  12 +-
 gdb/ia64-libunwind-tdep.h                     |  12 +-
 gdb/ia64-tdep.c                               |  54 +--
 gdb/ia64-tdep.h                               |   4 +-
 gdb/infcall.c                                 |   4 +-
 gdb/infcmd.c                                  |  30 +-
 gdb/inferior.h                                |   6 +-
 gdb/infrun.c                                  |  78 +++--
 gdb/infrun.h                                  |   4 +-
 gdb/inline-frame.c                            |  14 +-
 gdb/inline-frame.h                            |   4 +-
 gdb/iq2000-tdep.c                             |  10 +-
 gdb/jit.c                                     |  12 +-
 gdb/language.c                                |   6 +-
 gdb/language.h                                |   8 +-
 gdb/lm32-tdep.c                               |   8 +-
 gdb/loongarch-linux-tdep.c                    |   4 +-
 gdb/loongarch-tdep.c                          |   8 +-
 gdb/loongarch-tdep.h                          |   2 +-
 gdb/m32c-tdep.c                               |  10 +-
 gdb/m32r-linux-tdep.c                         |  14 +-
 gdb/m32r-tdep.c                               |   8 +-
 gdb/m68hc11-tdep.c                            |  16 +-
 gdb/m68k-linux-tdep.c                         |  12 +-
 gdb/m68k-tdep.c                               |  18 +-
 gdb/m68k-tdep.h                               |   2 +-
 gdb/macroscope.c                              |   2 +-
 gdb/mep-tdep.c                                |   8 +-
 gdb/mi/mi-cmd-stack.c                         |  29 +-
 gdb/mi/mi-main.c                              |  12 +-
 gdb/microblaze-linux-tdep.c                   |   4 +-
 gdb/microblaze-tdep.c                         |  10 +-
 gdb/minsyms.c                                 |   2 +-
 gdb/mips-fbsd-tdep.c                          |   4 +-
 gdb/mips-linux-tdep.c                         |  22 +-
 gdb/mips-netbsd-tdep.c                        |   2 +-
 gdb/mips-sde-tdep.c                           |  12 +-
 gdb/mips-tdep.c                               |  96 +++---
 gdb/mips-tdep.h                               |   2 +-
 gdb/mips64-obsd-tdep.c                        |   2 +-
 gdb/mn10300-linux-tdep.c                      |   4 +-
 gdb/mn10300-tdep.c                            |   8 +-
 gdb/moxie-tdep.c                              |   8 +-
 gdb/msp430-tdep.c                             |  10 +-
 gdb/nds32-tdep.c                              |  20 +-
 gdb/nios2-linux-tdep.c                        |   4 +-
 gdb/nios2-tdep.c                              |  22 +-
 gdb/nios2-tdep.h                              |   2 +-
 gdb/objc-lang.c                               |  10 +-
 gdb/observable.h                              |   2 +-
 gdb/or1k-linux-tdep.c                         |   4 +-
 gdb/or1k-tdep.c                               |  12 +-
 gdb/ppc-fbsd-tdep.c                           |   8 +-
 gdb/ppc-linux-tdep.c                          |  12 +-
 gdb/ppc-netbsd-tdep.c                         |   2 +-
 gdb/ppc-obsd-tdep.c                           |   8 +-
 gdb/ppc-tdep.h                                |   4 +-
 gdb/ppc64-tdep.c                              |  20 +-
 gdb/ppc64-tdep.h                              |   4 +-
 gdb/printcmd.c                                |   4 +-
 gdb/probe.c                                   |   4 +-
 gdb/probe.h                                   |   4 +-
 gdb/python/py-event.h                         |   2 +-
 gdb/python/py-finishbreakpoint.c              |   6 +-
 gdb/python/py-frame.c                         |  44 +--
 gdb/python/py-framefilter.c                   |  22 +-
 gdb/python/py-inferior.c                      |   2 +-
 gdb/python/py-infevents.c                     |   4 +-
 gdb/python/py-symbol.c                        |   6 +-
 gdb/python/py-unwind.c                        |  12 +-
 gdb/python/python-internal.h                  |   6 +-
 gdb/record-btrace.c                           |  32 +-
 gdb/riscv-fbsd-tdep.c                         |   2 +-
 gdb/riscv-linux-tdep.c                        |   6 +-
 gdb/riscv-tdep.c                              |  12 +-
 gdb/riscv-tdep.h                              |   2 +-
 gdb/rl78-tdep.c                               |  12 +-
 gdb/rs6000-aix-tdep.c                         |  10 +-
 gdb/rs6000-tdep.c                             |  34 +-
 gdb/rx-tdep.c                                 |  16 +-
 gdb/s12z-tdep.c                               |  10 +-
 gdb/s390-linux-tdep.c                         |   8 +-
 gdb/s390-tdep.c                               |  38 +--
 gdb/s390-tdep.h                               |   2 +-
 gdb/sentinel-frame.c                          |   6 +-
 gdb/sh-linux-tdep.c                           |   6 +-
 gdb/sh-tdep.c                                 |  16 +-
 gdb/skip.c                                    |   2 +-
 gdb/sol2-tdep.c                               |   2 +-
 gdb/sol2-tdep.h                               |   2 +-
 gdb/solib-svr4.c                              |   4 +-
 gdb/sparc-linux-tdep.c                        |   6 +-
 gdb/sparc-netbsd-tdep.c                       |  12 +-
 gdb/sparc-obsd-tdep.c                         |   8 +-
 gdb/sparc-sol2-tdep.c                         |   8 +-
 gdb/sparc-tdep.c                              |  20 +-
 gdb/sparc-tdep.h                              |  12 +-
 gdb/sparc64-fbsd-tdep.c                       |   8 +-
 gdb/sparc64-linux-tdep.c                      |   8 +-
 gdb/sparc64-netbsd-tdep.c                     |  10 +-
 gdb/sparc64-obsd-tdep.c                       |  16 +-
 gdb/sparc64-sol2-tdep.c                       |   8 +-
 gdb/sparc64-tdep.c                            |  10 +-
 gdb/sparc64-tdep.h                            |   4 +-
 gdb/stack.c                                   | 119 ++++---
 gdb/stack.h                                   |   4 +-
 gdb/stap-probe.c                              |   4 +-
 gdb/std-regs.c                                |   8 +-
 gdb/symfile.h                                 |   2 +-
 gdb/symtab.h                                  |  10 +-
 .../gdb.python/pretty-print-call-by-hand.c    |  53 +++
 .../gdb.python/pretty-print-call-by-hand.exp  | 136 ++++++++
 .../gdb.python/pretty-print-call-by-hand.py   |  41 +++
 gdb/tic6x-linux-tdep.c                        |   4 +-
 gdb/tic6x-tdep.c                              |  22 +-
 gdb/tic6x-tdep.h                              |   2 +-
 gdb/tilegx-linux-tdep.c                       |   2 +-
 gdb/tilegx-tdep.c                             |  12 +-
 gdb/top.c                                     |   2 +-
 gdb/tracepoint.c                              |   5 +-
 gdb/trad-frame.c                              |  10 +-
 gdb/trad-frame.h                              |  10 +-
 gdb/tramp-frame.c                             |  10 +-
 gdb/tramp-frame.h                             |   6 +-
 gdb/tui/tui-disasm.c                          |   2 +-
 gdb/tui/tui-disasm.h                          |   2 +-
 gdb/tui/tui-hooks.c                           |   6 +-
 gdb/tui/tui-regs.c                            |   8 +-
 gdb/tui/tui-regs.h                            |   4 +-
 gdb/tui/tui-source.c                          |   4 +-
 gdb/tui/tui-source.h                          |   2 +-
 gdb/tui/tui-stack.c                           |   4 +-
 gdb/tui/tui-stack.h                           |   4 +-
 gdb/tui/tui-winsource.c                       |   4 +-
 gdb/tui/tui-winsource.h                       |   2 +-
 gdb/user-regs.c                               |   4 +-
 gdb/user-regs.h                               |   6 +-
 gdb/v850-tdep.c                               |  10 +-
 gdb/valops.c                                  |  10 +-
 gdb/value.c                                   |   6 +-
 gdb/value.h                                   |  16 +-
 gdb/varobj.c                                  |   8 +-
 gdb/vax-tdep.c                                |  14 +-
 gdb/xstormy16-tdep.c                          |  12 +-
 gdb/xtensa-tdep.c                             |  22 +-
 gdb/z80-tdep.c                                |   6 +-
 gdbsupport/intrusive_list.h                   |  10 +-
 257 files changed, 2205 insertions(+), 1733 deletions(-)
 create mode 100644 gdb/frame-id.h
 create mode 100644 gdb/frame-info.h
 create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.c
 create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
 create mode 100644 gdb/testsuite/gdb.python/pretty-print-call-by-hand.py

-- 
2.31.1


             reply	other threads:[~2022-07-25 17:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25 17:06 Bruno Larsen via Gdb-patches [this message]
2022-07-25 17:06 ` [PATCH v3 1/5] Remove frame_id_eq Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 2/5] Introduce frame_info_ptr smart pointer class Bruno Larsen via Gdb-patches
2022-07-25 17:52   ` Pedro Alves
2022-08-24 14:24     ` Bruno Larsen via Gdb-patches
2022-08-24 15:20       ` Pedro Alves
2022-08-24 15:49         ` Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 3/5] Change GDB to use frame_info_ptr Bruno Larsen via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 4/5] Continue making GDB " Bruno Larsen via Gdb-patches
2022-07-28 16:44   ` Andrew Burgess via Gdb-patches
2022-07-25 17:06 ` [PATCH v3 5/5] gdb/frame: Add reinflation method for frame_info_ptr Bruno Larsen via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220725170637.79699-1-blarsen@redhat.com \
    --to=gdb-patches@sourceware.org \
    --cc=blarsen@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox