This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Fix tst-getpid{1,2} on ia64


Hi!

When glibc is built with gcc-4_0-branch on IA-64, tst-getpid{1,2}
fails.  The problem is that while older GCCs always aligned
buffer as big as char st[256 * 1024]; to 16 bytes, GCC 4 only
aligns this to 8 bytes.
Now, either we require direct clone/__clone2 users to make sure
the stack passed to it is sufficiently aligned (as done e.g. in
the patch below, 64 is just a guess for all arches out there,
I think e.g. IA-64 needs just 16 bytes alingment), or we make sure
that glibc's __clone2 and clone align things themselves, or we
make sure the kernel aligns it.

2005-03-08  Jakub Jelinek  <jakub@redhat.com>

	* tst-getpid1.c: Include stdint.h.
	(do_test): Align stack passed to clone{2,} to 64 bytes.

--- libc/nptl/tst-getpid1.c.jj	2004-12-15 12:16:06.000000000 +0100
+++ libc/nptl/tst-getpid1.c	2005-03-08 16:54:43.947924210 +0100
@@ -1,6 +1,7 @@
 #include <sched.h>
 #include <signal.h>
 #include <string.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -44,11 +45,13 @@ do_test (void)
   extern int __clone2 (int (*__fn) (void *__arg), void *__child_stack_base,
 		       size_t __child_stack_size, int __flags,
 		       void *__arg, ...);
-  char st[256 * 1024];
-  pid_t p = __clone2 (f, st, sizeof (st), TEST_CLONE_FLAGS, 0);
+  char st[256 * 1024 + 64];
+  char *stp = (char *) ((uintptr_t) (st + 64) & -64);
+  pid_t p = __clone2 (f, stp, sizeof (st) - 64, TEST_CLONE_FLAGS, 0);
 #else
-  char st[128 * 1024];
-  pid_t p = clone (f, st + sizeof (st), TEST_CLONE_FLAGS, 0);
+  char st[128 * 1024 + 64];
+  char *stp = (char *) ((uintptr_t) (st + 64) & -64);
+  pid_t p = clone (f, stp + sizeof (st) - 64, TEST_CLONE_FLAGS, 0);
 #endif
   if (p == -1)
     {

	Jakub


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