public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 1/9] Fix crash in amd64-tdep.c
Date: Fri,  7 Oct 2022 12:01:12 -0600	[thread overview]
Message-ID: <20221007180120.1866772-2-tromey@adacore.com> (raw)
In-Reply-To: <20221007180120.1866772-1-tromey@adacore.com>

amd64-tdep.c could crash when 'finish'ing from a function whose return
type had variable length.  In this situation, the value will be passed
by reference, and this patch avoids the crash.

(Note that this does not fully fix the bug reported, but it does fix
the crash, so it seems worthwhile to land independently.)
---
 gdb/amd64-tdep.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index ea2b3b1ecc3..22d69c85387 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -666,7 +666,8 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2])
 	loc_bitpos attributes, which will cause an assert to trigger within
 	the unaligned field check.  As classes with virtual bases are not
 	trivially copyable, checking that first avoids this problem.  */
-  if (type->length () > 16
+  if (TYPE_HAS_DYNAMIC_LENGTH (type)
+      || type->length () > 16
       || !language_pass_by_reference (type).trivially_copyable
       || amd64_has_unaligned_fields (type))
     {
-- 
2.34.3


  reply	other threads:[~2022-10-07 18:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07 18:01 [PATCH 0/9] Fix "finish" with variably-sized types Tom Tromey
2022-10-07 18:01 ` Tom Tromey [this message]
2022-10-07 18:01 ` [PATCH 2/9] Add new overload of gdbarch_return_value Tom Tromey
2022-10-07 18:01 ` [PATCH 3/9] Don't emit gdbarch_return_value Tom Tromey
2022-10-07 18:01 ` [PATCH 4/9] Introduce value_at_non_lval Tom Tromey
2022-10-07 18:01 ` [PATCH 5/9] Don't let property evaluation affect the current language Tom Tromey
2022-10-07 18:01 ` [PATCH 6/9] Convert selected architectures to gdbarch_return_value_as_value Tom Tromey
2022-10-07 18:01 ` [PATCH 7/9] Fix inferior calls with variably-sized return type Tom Tromey
2022-10-07 18:01 ` [PATCH 8/9] Use value_at_non_lval in get_call_return_value Tom Tromey
2022-10-07 18:01 ` [PATCH 9/9] Add test case for "finish" with variably-sized types Tom Tromey
2023-01-03 16:44 ` [PATCH 0/9] Fix " Tom Tromey

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=20221007180120.1866772-2-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).