public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "martinrb at google dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sources.redhat.com Subject: [Bug nptl/10311] New: clone(CLONE_VM) fails with pthread_getattr_np on i386 Date: Mon, 22 Jun 2009 19:23:00 -0000 [thread overview] Message-ID: <20090622192309.10311.martinrb@google.com> (raw) 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.
next reply other threads:[~2009-06-22 19:23 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-06-22 19:23 martinrb at google dot com [this message] 2009-06-22 19:32 ` [Bug nptl/10311] " martinrb at google dot com 2009-06-22 19:36 ` drepper at redhat dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090622192309.10311.martinrb@google.com \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sources.redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).