This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Fix for pr16196: Honor fetch limit for strings of known size
- From: Sterling Augustine <saugustine at google dot com>
- To: Doug Evans <dje at google dot com>
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Mon, 25 Nov 2013 15:55:16 -0800
- Subject: Re: Fix for pr16196: Honor fetch limit for strings of known size
- Authentication-results: sourceware.org; auth=none
- References: <CAEG7qUzi0uLcLuLweWURr1d4m+OdZb5MUo9q-imF8mgGtM7=CQ at mail dot gmail dot com> <CADPb22T7uxGzkfZTjdQu3F6a+LS=Esj=3tQ9o=WKt=3ZS1Xbdw at mail dot gmail dot com>
On Fri, Nov 22, 2013 at 12:35 PM, Doug Evans <dje@google.com> wrote:
> On Fri, Nov 22, 2013 at 12:02 PM, Sterling Augustine
> <saugustine@google.com> wrote:
>> The enclosed patch fixes 16196, which was revealed when an unitialized
>> C++ string happened to point to valid memory and had a garbage in the
>> size field that happened to look very large. GDB then spins a very
>> long time reading invalid memory.
>>
>> The patch fixes this by enforcing the fetch limit (which, in turn, is
>> set by print elements) even when the size of the string is known. This
>> makes the function's behavior similar to when the size of the string
>> isn't know.
>>
>> I checked all callers, and it this does not cause any difference in
>> behavior, and reveals no new problems in the test-suite.
>>
>> Thanks
>>
>> Sterling
>>
>> 2013-11-22 Sterling Augustine <saugustine@google.com>
>>
>> PR backtrace/16196:
>> * valprint.c (read_string): Set new variable fetchlen based on
>> fetchlimit and size. Use it in call to partial_memory_read.
>> Update comment.
>
> LGTM.
> [There are still other issues, but this patch doesn't have to fix all of them.]
>
> I'd change the "backtrace" in backtrace/16196 to something else, not
> sure what though.
> "gdb" is always a good fallback. PR gdb/16196.
Checked in with the minor ChangeLog fix as requested.