Re: [PATCH 1/1] perf record: Fix memset out-of-range error

From: Namhyung Kim
Date: Fri Jul 12 2024 - 12:46:00 EST


On Mon, 08 Jul 2024 02:01:00 +0800, Haoze Xie wrote:

> Modified the object of 'memset' from '&lost.lost' to '&lost' in
> record__read_lost_samples. This allows 'memset' to access memory properly
> without causing out-of-bounds problems.
>
> The problems got from builtin-record.c are:
>
> In file included from /usr/include/string.h:495,
> from util/parse-events.h:13,
> from builtin-record.c:14:
> In function 'memset',
> inlined from 'record__read_lost_samples' at
> builtin-record.c:1958:6,
> inlined from '__cmd_record.constprop' at builtin-record.c:2817:2:
> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:10: error:
> '__builtin_memset' offset [17, 64] from the object at 'lost' is out
> of the bounds of referenced subobject 'lost' with type
> 'struct perf_record_lost_samples' at offset 0 [-Werror=array-bounds]
> 71|return __builtin___memset_chk (__dest,__ch,__len,__bos0 (__dest));
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung