Re: gcc-8: mm/swapfile.c:863:40: error: array subscript 1 is above array bounds of 'struct list_head[1]' [-Werror=array-bounds]

From: Kairui Song
Date: Mon Aug 19 2024 - 07:44:57 EST


On Mon, Aug 19, 2024 at 6:16 PM Naresh Kamboju
<naresh.kamboju@xxxxxxxxxx> wrote:
>
> On Mon, 19 Aug 2024 at 13:58, Naresh Kamboju <naresh.kamboju@xxxxxxxxxx> wrote:
> >
> > The x86 builds failed with gcc-8 due to following build warnings / errors on
> > Linux next-20240802 to next-20240819.
> >
> > x86_64 defconfig gcc-8 build failed
> > x86_64 defconfig gcc-13 build pass
> >
> > First seen on the next-20240802 tag.
> >
> > GOOD: next-20240730
> > BAD: next-20240802
>
> Anders bisected this and found the first bad commit id as,
> aded4352f648 ("mm: swap: separate SSD allocation from
> scan_swap_map_slots()") first faulty one
>
> - Naresh
>

Hi Naresh,

Thanks for the report, the problem will occur when CONFIG_THP_SWAP is
disabled. Can you try the following patch? I can confirm it's fixed
with my test.

Attachment: 0001-mm-swap-fix-array-bounds-error-with-CONFIG_THP_SWAP-.patch
Description: Binary data