[PATCH] Fixed core dump from incorrect location expression on bad dwarfs
Alexandra Petlanova Hajkova
ahajkova@redhat.com
Mon Aug 30 15:30:58 GMT 2021
On Thu, Aug 26, 2021 at 3:19 PM Bruno Larsen via Gdb-patches <
gdb-patches@sourceware.org> wrote:
> Some incorrectly constructed location expressions in inheritance members
> of a class could lead to a core dump, or printing garbage instead of a
> correct value. The added test case always core dumped during my
> testing, but it could be changed to print garbage by changing the
> location expression on the exp file to not include DW_OP_stack_value,
> but just use a large constant value.
>
> The solution is, when copying contents of a value struct, check if
> contents will actually be copied (ie length > 0) and if the
> offset of the copied member is greater than the size of the struct
> itself, raising an error if so.
>
Hi,
the patch applies cleanly but it does not compile as it is.
It does compile with
&& (dst_offset >= TYPE_LENGTH (value_enclosing_type (dst))
|| src_offset >= TYPE_LENGTH (value_enclosing_type (src))))
instead of
&& (dst_offset >= TYPE_LENGTH (value_enclosing_type (dst->enclosing_type))
|| src_offset >= TYPE_LENGTH (value_enclosing_type
(src->enclosing_type))))
and seems to add no regressions.
More information about the Gdb-patches
mailing list