* gdb 8.0 "lazy_string" exception "Length is larger than array size"
@ 2017-09-25 19:55 Michael Stahl
2017-09-26 7:56 ` Phil Muldoon
0 siblings, 1 reply; 5+ messages in thread
From: Michael Stahl @ 2017-09-25 19:55 UTC (permalink / raw)
To: gdb
hi,
for the following string type:
/** The implementation of a Unicode string.
*/
typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
{
oslInterlockedCount refCount; /* opaque */
sal_Int32 length;
sal_Unicode buffer[1];
} rtl_uString;
the gdb python pretty-printer calls:
return data.lazy_string(encoding, length)
full python pretty-printer module:
https://gerrit.libreoffice.org/gitweb?p=core.git;a=blob;f=solenv/gdb/libreoffice/util/string.py;h=32583718f83b2ad5707f75dd6327d9aa62764439;hb=5f210715fe090b4db4c80dcdee5f77dc404cf85c#l56
now this results in this exception:
Traceback (most recent call last):
File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
29, in to_string
return self.make_string(data, self.encoding, len)
File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
66, in make_string
return data.lazy_string(encoding, length)
gdb.error: Length is larger than array size.
this is with Fedora 26 "GNU gdb (GDB) Fedora 8.0.1-26.fc26" - in Fedora
25 this did not throw an exception.
apparently the problem is that the array is statically declared as
"buffer[1]", however its actual dynamic size is the same as "length".
is this a bug in gdb or is lazy_string not intended to support this
scenario?
regards,
michael
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: gdb 8.0 "lazy_string" exception "Length is larger than array size"
2017-09-25 19:55 gdb 8.0 "lazy_string" exception "Length is larger than array size" Michael Stahl
@ 2017-09-26 7:56 ` Phil Muldoon
2017-09-26 8:06 ` Fwd: " Phil Muldoon
2017-09-26 10:30 ` Pedro Alves
0 siblings, 2 replies; 5+ messages in thread
From: Phil Muldoon @ 2017-09-26 7:56 UTC (permalink / raw)
To: Michael Stahl, gdb, Doug Evans, Doug Evans
On 25/09/17 18:20, Michael Stahl wrote:
>
> hi,
>
> for the following string type:
>
> /** The implementation of a Unicode string.
> */
> typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
> {
> oslInterlockedCount refCount; /* opaque */
> sal_Int32 length;
> sal_Unicode buffer[1];
> } rtl_uString;
>
> the gdb python pretty-printer calls:
>
> return data.lazy_string(encoding, length)
>
> full python pretty-printer module:
>
> https://gerrit.libreoffice.org/gitweb?p=core.git;a=blob;f=solenv/gdb/libreoffice/util/string.py;h=32583718f83b2ad5707f75dd6327d9aa62764439;hb=5f210715fe090b4db4c80dcdee5f77dc404cf85c#l56
>
> now this results in this exception:
>
> Traceback (most recent call last):
> File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
> 29, in to_string
> return self.make_string(data, self.encoding, len)
> File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
> 66, in make_string
> return data.lazy_string(encoding, length)
> gdb.error: Length is larger than array size.
>
> this is with Fedora 26 "GNU gdb (GDB) Fedora 8.0.1-26.fc26" - in Fedora
> 25 this did not throw an exception.
>
> apparently the problem is that the array is statically declared as
> "buffer[1]", however its actual dynamic size is the same as "length".
>
> is this a bug in gdb or is lazy_string not intended to support this
> scenario?
>
> regards,
> michael
>
Yeah, it's determining the string is an array and finding that the
declared length is larger then the array size. This is (as you noted)
the initial length of the array is [1] and that array is then
modified later. This code was added at 34b433203b5 by Doug Evans and
it was noted it was a bug. I've not sure, though, fixing this bug
may have had unintended consequences. I've CC'd Doug on the patch
and maybe he could comment further.
Cheers
Phil
^ permalink raw reply [flat|nested] 5+ messages in thread* Fwd: Re: gdb 8.0 "lazy_string" exception "Length is larger than array size"
2017-09-26 7:56 ` Phil Muldoon
@ 2017-09-26 8:06 ` Phil Muldoon
2017-09-26 10:30 ` Pedro Alves
1 sibling, 0 replies; 5+ messages in thread
From: Phil Muldoon @ 2017-09-26 8:06 UTC (permalink / raw)
To: gdb
Oops noticed original email was addressed to gdb@gnu.org. I don't
think this is an alias for gdb@sourceware.org so forwarding my reply
for completeness.
Cheers
Phil
-------- Forwarded Message --------
Subject: Re: gdb 8.0 "lazy_string" exception "Length is larger than array size"
Date: Tue, 26 Sep 2017 08:56:03 +0100
From: Phil Muldoon <pmuldoon@redhat.com>
To: Michael Stahl <mstahl@redhat.com>, gdb@gnu.org, Doug Evans <dje@google.com>, Doug Evans <xdje42@gmail.com>
On 25/09/17 18:20, Michael Stahl wrote:
>
> hi,
>
> for the following string type:
>
> /** The implementation of a Unicode string.
> */
> typedef struct SAL_DLLPUBLIC_RTTI _rtl_uString
> {
> oslInterlockedCount refCount; /* opaque */
> sal_Int32 length;
> sal_Unicode buffer[1];
> } rtl_uString;
>
> the gdb python pretty-printer calls:
>
> return data.lazy_string(encoding, length)
>
> full python pretty-printer module:
>
> https://gerrit.libreoffice.org/gitweb?p=core.git;a=blob;f=solenv/gdb/libreoffice/util/string.py;h=32583718f83b2ad5707f75dd6327d9aa62764439;hb=5f210715fe090b4db4c80dcdee5f77dc404cf85c#l56
>
> now this results in this exception:
>
> Traceback (most recent call last):
> File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
> 29, in to_string
> return self.make_string(data, self.encoding, len)
> File "/work/lo/master/solenv/gdb/libreoffice/util/string.py", line
> 66, in make_string
> return data.lazy_string(encoding, length)
> gdb.error: Length is larger than array size.
>
> this is with Fedora 26 "GNU gdb (GDB) Fedora 8.0.1-26.fc26" - in Fedora
> 25 this did not throw an exception.
>
> apparently the problem is that the array is statically declared as
> "buffer[1]", however its actual dynamic size is the same as "length".
>
> is this a bug in gdb or is lazy_string not intended to support this
> scenario?
>
> regards,
> michael
>
Yeah, it's determining the string is an array and finding that the
declared length is larger then the array size. This is (as you noted)
the initial length of the array is [1] and that array is then
modified later. This code was added at 34b433203b5 by Doug Evans and
it was noted it was a bug. I've not sure, though, fixing this bug
may have had unintended consequences. I've CC'd Doug on the patch
and maybe he could comment further.
Cheers
Phil
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: gdb 8.0 "lazy_string" exception "Length is larger than array size"
2017-09-26 7:56 ` Phil Muldoon
2017-09-26 8:06 ` Fwd: " Phil Muldoon
@ 2017-09-26 10:30 ` Pedro Alves
2017-09-29 15:06 ` Michael Stahl
1 sibling, 1 reply; 5+ messages in thread
From: Pedro Alves @ 2017-09-26 10:30 UTC (permalink / raw)
To: Phil Muldoon, Michael Stahl, gdb, Doug Evans, Doug Evans
On 09/26/2017 08:56 AM, Phil Muldoon wrote:
> On 25/09/17 18:20, Michael Stahl wrote:
> This code was added at 34b433203b5 by Doug Evans and
> it was noted it was a bug. I've not sure, though, fixing this bug
> may have had unintended consequences. I've CC'd Doug on the patch
> and maybe he could comment further.
We could perhaps decide to special case trailing arrays of
lengths 0 and 1 (i.e., let the caller request more elements than
declared), assuming they're being used as the trailing array
idiom, similarly to how gcc also has special concessions for those.
I don't know off hand whether its easy for the gdb code in question
to tell whether the array is the last field of a struct, though
I'd assume not.
If you want to ignore the array's declared length, I think you can
always decay 'buffer' to a pointer and work with that, and then GDB
won't have a length to validate.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: gdb 8.0 "lazy_string" exception "Length is larger than array size"
2017-09-26 10:30 ` Pedro Alves
@ 2017-09-29 15:06 ` Michael Stahl
0 siblings, 0 replies; 5+ messages in thread
From: Michael Stahl @ 2017-09-29 15:06 UTC (permalink / raw)
To: gdb
On 26.09.2017 12:30, Pedro Alves wrote:
> If you want to ignore the array's declared length, I think you can
> always decay 'buffer' to a pointer and work with that, and then GDB
> won't have a length to validate.
thanks, replacing
['buffer']
with
['buffer'].address
in the pretty printer avoids the exception!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-29 15:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 19:55 gdb 8.0 "lazy_string" exception "Length is larger than array size" Michael Stahl
2017-09-26 7:56 ` Phil Muldoon
2017-09-26 8:06 ` Fwd: " Phil Muldoon
2017-09-26 10:30 ` Pedro Alves
2017-09-29 15:06 ` Michael Stahl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox