Subject: bug#29886: tests/rm/rm-readdir-fail is failing with SIGBUS on Gentoo sparc

From: Thomas Deutschmann <[email-masked]>
Date: Wed, 11 Jul 2018 18:53:40 +0200

On 2018-07-11 04:46, Paul Eggert wrote:
> Thomas Deutschmann wrote:
>> -                p->fts_statp->st_ino = D_INO (dp);
>> +                memcpy(&p->fts_statp->st_ino, &dp,
>> sizeof(p->fts_statp->st_ino));
> 
> This looks like a kernel bug, not a coreutils bug. readdir must be
> returning a pointer to an misaligned struct. Can you look into that? For
> example, what happens if you insert this:
> 
>   if ((intptr_t) (dp) % _Alignof (struct dirent) != 0)
>      abort ();
> 
> before the memcpy? The 'abort ()' should never happen; if it does,
> there's a bug in readdir, surely.

Not sure if this is a kernel problem. Isn't test suite using
LD_PRELOAD to pull in additional libraries which could cause
such a breakage? And wouldn't "rm" show any failure during normal
use?

The sparc user added the requested debug code and confirmed that
abort() will be triggered.

#0  0xf7e230fc in raise () from /lib/libc.so.6
#1  0xf7e25240 in abort () from /lib/libc.so.6
#2  0x0001813c in fts_build (sp=sp@entry=0x309c0, type=type@entry=3) at lib/fts.c:1555
#3  0x00018bd0 in fts_read (sp=sp@entry=0x309c0) at lib/fts.c:966
#4  0x00012750 in rm (file=file@entry=0xffffc95c, x=x@entry=0xffffc7f4) at src/remove.c:596
#5  0x00011564 in main (argc=<optimized out>, argv=<optimized out>) at src/rm.c:370
(gdb) frame 2
(gdb) p dp
$1 = (struct dirent *) 0x31dcc

User said it is also always going through

#0  0xf7fb4684 in readdir64 () from ./k.so

Kernel: Linux castor 4.16.8 #1 SMP Tue May 15 22:40:58 CEST 2018 sparc64 sun4v UltraSparc T2 (Niagara2) GNU/Linux

-- 
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5