public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 2/2] gdb/dwarf: fix UBsan crash in read_subrange_type
Date: Fri, 20 Jan 2023 11:51:29 -0500	[thread overview]
Message-ID: <92b91e11-10bc-ff5a-1bde-901ae8e3388f@simark.ca> (raw)
In-Reply-To: <87fsc5e4tu.fsf@redhat.com>


>> @@ -17684,15 +17683,25 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
>>       with GCC, for instance, where the ambiguous DW_FORM_dataN form
>>       is used instead.  To work around that ambiguity, we treat
>>       the bounds as signed, and thus sign-extend their values, when
>> -     the base type is signed.  */
>> -  negative_mask =
>> -    -((ULONGEST) 1 << (base_type->length () * TARGET_CHAR_BIT - 1));
>> -  if (low.kind () == PROP_CONST
>> -      && !base_type->is_unsigned () && (low.const_val () & negative_mask))
>> -    low.set_const_val (low.const_val () | negative_mask);
>> -  if (high.kind () == PROP_CONST
>> -      && !base_type->is_unsigned () && (high.const_val () & negative_mask))
>> -    high.set_const_val (high.const_val () | negative_mask);
>> +     the base type is signed.
>> +
>> +     Skip it if the base type's length is largest than ULONGEST, to avoid
> 
> s/largest/larger/

Fixed.

>> @@ -92,3 +112,5 @@ gdb_test "ptype TByteArray" \
>>      "type = array \\\[0\\.\\.191\\\] of byte"
>>  gdb_test "ptype subrange_with_buggy_negative_bounds_variable" \
>>      "type = -16..-12"
>> +gdb_test "ptype a_16_byte_subrange_variable" \
>> +    "type = -9223372036854775808..9223372036854775807"
> 
> As before, I'd use "\\.\\." here.

Fixed.

> Looks good with those nits fixed.

Thanks, will push.

Simon

  reply	other threads:[~2023-01-20 16:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20  5:08 [PATCH 1/2] gdb/testsuite: add test for negative subrange bounds with unsigned form Simon Marchi
2023-01-20  5:08 ` [PATCH 2/2] gdb/dwarf: fix UBsan crash in read_subrange_type Simon Marchi
2023-01-20 13:03   ` Andrew Burgess
2023-01-20 16:51     ` Simon Marchi [this message]
2023-01-20 12:51 ` [PATCH 1/2] gdb/testsuite: add test for negative subrange bounds with unsigned form Andrew Burgess
2023-01-20 16:38   ` Simon Marchi

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=92b91e11-10bc-ff5a-1bde-901ae8e3388f@simark.ca \
    --to=simark@simark.ca \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).