public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Fix a couple undefined behaviors flagged by UBSan
@ 2022-04-07 20:06 Pedro Alves
  2022-04-07 20:06 ` [PATCH v3 1/2] Fix undefined behavior in the Fortran, Go and Pascal number parsers Pedro Alves
  2022-04-07 20:06 ` [PATCH v3 2/2] gdb: Avoid undefined shifts, fix Go shifts Pedro Alves
  0 siblings, 2 replies; 8+ messages in thread
From: Pedro Alves @ 2022-04-07 20:06 UTC (permalink / raw)
  To: gdb-patches

New in v3:
  - The scheme patch has been merged meanwhile.

  - There's a new patch to fix "print 0xffffffffffffffff" in a couple
    languages.  This also triggered undefined behavior.  Discovered
    while extending the bit shift testcase to run to on all languages.

  - The patch that fixes bit shifts in all languages was improved
    substantially:

    - The testcase now exercises all languages that have shift
      operators, instead of just C.

    - The testcase now uses with_test_prefix.

    - properly handles the case where the rhs of a shift is
      0xffffffffffffffff (max 64-bit), and only warning that being
      negative if it really is negative.

    - error out on negative shifts for Go, warn on other languages.

    - don't error or warn on too-large shift for Go, as that's
      actually defined in Go.

    - Right shifts of a too-large count now result in -1 if the result
      is signed, instead of 0.

Running the testsuite against GDBserver with a GDB built with
--enable-ubsan, I noticed a few problems.  This mini-series fixes a
couple.

Pedro Alves (2):
  Fix undefined behavior in the Fortran, Go and Pascal number parsers
  gdb: Avoid undefined shifts, fix Go shifts

 gdb/f-exp.y                                   |   8 +-
 gdb/go-exp.y                                  |  10 +-
 gdb/p-exp.y                                   |  12 +-
 .../gdb.base/all-architectures.exp.tcl        |  32 +-
 gdb/testsuite/gdb.base/bitshift.exp           | 368 ++++++++++++++++++
 gdb/testsuite/gdb.base/parse_number.exp       |  53 +++
 gdb/testsuite/lib/gdb.exp                     |  20 +
 gdb/valarith.c                                | 103 ++++-
 8 files changed, 560 insertions(+), 46 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/bitshift.exp
 create mode 100644 gdb/testsuite/gdb.base/parse_number.exp


base-commit: 591cc9fbbfd6d51131c0f1d4a92e7893edcc7a28
-- 
2.26.2


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 20:06 [PATCH v3 0/2] Fix a couple undefined behaviors flagged by UBSan Pedro Alves
2022-04-07 20:06 ` [PATCH v3 1/2] Fix undefined behavior in the Fortran, Go and Pascal number parsers Pedro Alves
2022-04-08 14:44   ` Tom Tromey
2022-04-08 14:58     ` Pedro Alves
2022-04-08 15:22       ` Tom Tromey
2022-04-07 20:06 ` [PATCH v3 2/2] gdb: Avoid undefined shifts, fix Go shifts Pedro Alves
2022-04-08 14:55   ` Tom Tromey
2022-04-08 15:20     ` Pedro Alves

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