public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/10311] New: clone(CLONE_VM) fails with pthread_getattr_np on i386
@ 2009-06-22 19:23 martinrb at google dot com
2009-06-22 19:32 ` [Bug nptl/10311] " martinrb at google dot com
2009-06-22 19:36 ` drepper at redhat dot com
0 siblings, 2 replies; 3+ messages in thread
From: martinrb at google dot com @ 2009-06-22 19:23 UTC (permalink / raw)
To: glibc-bugs
I'm using clone() with flags CLONE_VM, but not CLONE_THREAD.
(background: I'm trying to solve the ancient overcommit failure
when spawning a small Unix process from a big process).
The act of calling clone appears to mess up the pthread library,
but only on i386, not on x86_64, using glibc version 2.7
(The bugzilla Version drop-down does not allow one to specify 2.7;
y'all should fix that)
Here's a shell transcript containing a program
that demonstrates the problem, and shows that
the problem does not occur when running in 64-bit mode
on 64-bit Linux. (The problem also occurs when running in 32-bit mode
on 32-bit Linux).
A program like this would be a fine addition to the glibc test suite.
$ set -x; for flag in -m32 -m64; do gcc $flag -lpthread ./clone_bug.c &&
./a.out; done; cat clone_bug.c; uname -a; getconf GNU_LIBPTHREAD_VERSION;
getconf GNU_LIBC_VERSION
+zsh:1464> set -x
+zsh:1464> flag=-m32
+zsh:1464> gcc -m32 -lpthread ./clone_bug.c
+zsh:1464> ./a.out
count=2, pthread_getattr_np failed with errno = "No such process"
+zsh:1464> flag=-m64
+zsh:1464> gcc -m64 -lpthread ./clone_bug.c
+zsh:1464> ./a.out
+zsh:1464> cat clone_bug.c
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <sys/types.h>
#include <wait.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <syscall.h>
#include <sched.h>
static void
debugPrint(char *format, ...) {
FILE *tty = fopen("/dev/tty", "w");
va_list ap;
va_start(ap, format);
vfprintf(tty, format, ap);
va_end(ap);
fclose(tty);
}
static void debugPids(void) {
// debugPrint("getpid()=%d gettid()=%d, syscall(getpid)=%d pthread_self=%d\n",
// getpid(), syscall(SYS_gettid), syscall(SYS_getpid), pthread_self());
static int count = 0;
pthread_attr_t attr;
int result;
++count;
if ((result = pthread_getattr_np(pthread_self(), &attr)) != 0)
debugPrint("count=%d, pthread_getattr_np failed with errno = \"%s\"\n",
count, strerror(result));
}
static int childProcess(void *ignored) {
_exit(0);
// debugPrint("child\n");
// execve("/bin/true", NULL, NULL);
// perror("execve");
}
// I'm sure there's a better way to do this,
// but pthread_join ain't it - we can't trust it.
volatile int done = 0;
void* run(void *x) {
const int stack_size = 1024 * 1024;
void *clone_stack = malloc(2 * stack_size);
int status;
debugPids();
int pid = clone(childProcess, clone_stack + stack_size,
CLONE_VM | SIGCHLD, NULL);
waitpid(pid, &status, 0);
debugPids();
done = 1;
pthread_exit(0);
return NULL;
}
int main(int argc, char *argv[]) {
pthread_attr_t attr;
pthread_t tid;
pthread_attr_init(&attr);
pthread_create(&tid, &attr, (void* (*)(void*)) run, NULL);
// pthread_join(tid, NULL);
while (! done)
;
}
+zsh:1464> uname -a
Linux spraggett.mtv.corp.google.com 2.6.24-gg23-generic #1 SMP Fri Jan 30
14:07:49 PST 2009 x86_64 GNU/Linux
+zsh:1464> getconf GNU_LIBPTHREAD_VERSION
NPTL 2.7
+zsh:1464> getconf GNU_LIBC_VERSION
glibc 2.7
--
Summary: clone(CLONE_VM) fails with pthread_getattr_np on i386
Product: glibc
Version: 2.8
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: martinrb at google dot com
CC: glibc-bugs at sources dot redhat dot com
GCC host triplet: x86_64-unknown-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=10311
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug nptl/10311] clone(CLONE_VM) fails with pthread_getattr_np on i386
2009-06-22 19:23 [Bug nptl/10311] New: clone(CLONE_VM) fails with pthread_getattr_np on i386 martinrb at google dot com
@ 2009-06-22 19:32 ` martinrb at google dot com
2009-06-22 19:36 ` drepper at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: martinrb at google dot com @ 2009-06-22 19:32 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From martinrb at google dot com 2009-06-22 19:32 -------
I'm not sure whether this is
- a glibc bug in the implementation of clone()
- a kernel bug in the implementation of the clone syscall
- or simply an unsupported combination of FLAGS.
The fact that the various versions of clone.S explicitly test for
CLONE_VM and CLONE_THREAD and take different action suggest that
what I'm doing in the test case should work.
I am suspecting a bug in
sysdeps/unix/sysv/linux/i386/clone.S
but this is deep magic x86 assembly language,
and I'm not competent to debug it.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=10311
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug nptl/10311] clone(CLONE_VM) fails with pthread_getattr_np on i386
2009-06-22 19:23 [Bug nptl/10311] New: clone(CLONE_VM) fails with pthread_getattr_np on i386 martinrb at google dot com
2009-06-22 19:32 ` [Bug nptl/10311] " martinrb at google dot com
@ 2009-06-22 19:36 ` drepper at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: drepper at redhat dot com @ 2009-06-22 19:36 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2009-06-22 19:35 -------
If you use clone() you're on your own.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
http://sourceware.org/bugzilla/show_bug.cgi?id=10311
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-22 19:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-22 19:23 [Bug nptl/10311] New: clone(CLONE_VM) fails with pthread_getattr_np on i386 martinrb at google dot com
2009-06-22 19:32 ` [Bug nptl/10311] " martinrb at google dot com
2009-06-22 19:36 ` drepper at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).