Fix for pr16196: Honor fetch limit for strings of known size

Sterling Augustine saugustine@google.com
Tue Nov 26 02:58:00 GMT 2013


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.



More information about the Gdb-patches mailing list