This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sparc 32-bit dirent broken

From: David Miller <>
Date: Thu, 10 Oct 2013 17:06:28 -0400 (EDT)

> I'll test out this theory.

Indeed, the following patch fixes the bug.  We were just being lucky
beforehand in that the off_t was 64-bit and therefore making the
data[] array be 64-bit aligned as well.  Once you add the errcode
there it is only 4-byte aligned.

On powerpc/x86-32 there are no alignment traps, so you wouldn't notice
this problem on those platforms.

The critical element is whatever alignment d_off/d_ino need, that can
be either __off_t/__ino_t or __off64_t/__ino64_t.

Any suggestions for a better alignof or is this good enough to fix
the problem?  We probably should have a per-sysdep definition of
"largest C type alignment" so we can use it in situations like this.

diff --git a/sysdeps/posix/dirstream.h b/sysdeps/posix/dirstream.h
index 8e8570d..bf221db 100644
--- a/sysdeps/posix/dirstream.h
+++ b/sysdeps/posix/dirstream.h
@@ -42,7 +42,7 @@ struct __dirstream
     int errcode;		/* Delayed error code.  */
     /* Directory block.  */
-    char data[0] __attribute__ ((aligned (__alignof__ (void*))));
+    char data[0] __attribute__ ((aligned (__alignof__ (unsigned long long))));
 #define _DIR_dirfd(dirp)	((dirp)->fd)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]