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

From: Paul Eggert <[email-masked]>
Date: Wed, 11 Jul 2018 10:05:59 -0700

Thomas Deutschmann wrote:

> 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?

You're right, it could be a library problem. The test suite's LD_PRELOAD library 
just returns what the C library gives it, though. Perhaps LD_PRELOAD usage is 
messing up malloc on your platform, so that it returns improperly-aligned 
pointers? You might try something like the attached patch to see whether the C 
library is doing that.

> And wouldn't "rm" show any failure during normal use?

Yes, one would think so.

In any case, this is not sounding like a bug in coreutils itself.
diff --git a/tests/rm/rm-readdir-fail.sh b/tests/rm/rm-readdir-fail.sh
index 75fa339db..8d74aaefd 100755
--- a/tests/rm/rm-readdir-fail.sh
+++ b/tests/rm/rm-readdir-fail.sh
@@ -55,6 +55,8 @@ struct dirent *readdir (DIR *dirp)
       return NULL;
     }
 
+  if ((long) (d) % _Alignof (struct dirent) != 0)
+    abort ();
   /* Flag that LD_PRELOAD and above functions work.  */
   static int count = 1;
   if (count == 1)