[0/4] Some alloca removal and a printf bug fix

Message ID cover.1685611212.git.aburgess@redhat.com
Headers
Series Some alloca removal and a printf bug fix |

Message

Andrew Burgess June 1, 2023, 9:27 a.m. UTC
  I previously posted this series in an attempt to remove lots of alloca use:

  https://inbox.sourceware.org/gdb-patches/cover.1677533215.git.aburgess@redhat.com/

there was some push back against that complete series, however, I
think the problem that was pointed out doesn't apply to one of the
original patches, so this series started with me trying to upstream
that one patch (this is patch #2 in this series).

However, while reviewing the patch again I spotted a bug I'd
introduced.  Which means we have a gap in our testing, as the bug was
not exposed during testing.  So I started to write a test, and hit
another bug (not one introduced by me), this is fixed in patch #1 in
this series.

My original series didn't remove all the uses of alloca from
printcmd.c, I don't recall why.  But on review it's actually pretty
easy to remove the final alloca from printcmd.c, so that's what
patch #3 in this series does.

And finally, while working on patch #2 I realised that a badly formed
inferior (e.g. one that needed debugging due to memory corruption)
could cause GDB to try and allocate a huge ammount of memory,
potentially crashing GDB.  This is mitigated in patch #4.

---

Andrew Burgess (4):
  gdb: fix printf of wchar_t early in a gdb session
  gdb: remove two uses of alloca from printcmd.c
  gdb: remove last alloca call from printcmd.c
  gdb: check max-value-size when reading strings for printf

 gdb/c-lang.c                              |   3 -
 gdb/gdbtypes.c                            |  11 ++-
 gdb/gdbtypes.h                            |  14 ++-
 gdb/printcmd.c                            | 102 +++++++++++++---------
 gdb/testsuite/gdb.base/printcmds.c        |   2 +
 gdb/testsuite/gdb.base/printcmds.exp      |   5 ++
 gdb/testsuite/gdb.base/printf-wchar_t.c   |  28 ++++++
 gdb/testsuite/gdb.base/printf-wchar_t.exp |  32 +++++++
 gdb/testsuite/lib/gdb.exp                 |  30 +++++++
 gdb/value.c                               |  10 ++-
 gdb/value.h                               |   5 ++
 11 files changed, 192 insertions(+), 50 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/printf-wchar_t.c
 create mode 100644 gdb/testsuite/gdb.base/printf-wchar_t.exp


base-commit: e9683acf5e51c2bac8aa68d30d9ac3683dddcc7d
  

Comments

Tom Tromey June 2, 2023, 5:06 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> there was some push back against that complete series, however, I
Andrew> think the problem that was pointed out doesn't apply to one of the
Andrew> original patches, so this series started with me trying to upstream
Andrew> that one patch (this is patch #2 in this series).

FWIW I read through these and I think they are fine.

Tom
  
Andrew Burgess July 7, 2023, 2:34 p.m. UTC | #2
Tom Tromey <tom@tromey.com> writes:

>>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Andrew> there was some push back against that complete series, however, I
> Andrew> think the problem that was pointed out doesn't apply to one of the
> Andrew> original patches, so this series started with me trying to upstream
> Andrew> that one patch (this is patch #2 in this series).
>
> FWIW I read through these and I think they are fine.

I pushed this series.

Thanks,
Andrew