From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25359 invoked by alias); 15 Sep 2008 18:59:47 -0000 Received: (qmail 25350 invoked by uid 22791); 15 Sep 2008 18:59:46 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 15 Sep 2008 18:59:12 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m8FIuVOo019244; Mon, 15 Sep 2008 14:56:31 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m8FIuTEB014529; Mon, 15 Sep 2008 14:56:30 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m8FIuSbk001209; Mon, 15 Sep 2008 14:56:28 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.2) with ESMTP id m8FIuREw025572; Mon, 15 Sep 2008 20:56:27 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id m8FIuRoX025565; Mon, 15 Sep 2008 20:56:27 +0200 Date: Mon, 15 Sep 2008 18:59:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [patch] Fix a crash on NULL event_thread Message-ID: <20080915185627.GA25128@host0.dyn.jankratochvil.net> References: <20080912221227.GA5848@host0.dyn.jankratochvil.net> <200809122344.55797.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline In-Reply-To: <200809122344.55797.pedro@codesourcery.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00338.txt.bz2 --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1366 On Sat, 13 Sep 2008 00:44:55 +0200, Pedro Alves wrote: > On Friday 12 September 2008 23:12:27, Jan Kratochvil wrote: > > various testcases - such as gdb.threads/bp_in_thread.exp - crash HEAD. > > Tested only on Fedora kernel-2.6.27-0.317.rc5.git10.fc10.x86_64 but I > > expect it can happen anywhere. > > > > LINUX_HANDLE_EXTENDED_WAIT calls ADD_LWP but not ADD_THREAD. > > Hmm, it may be due to something having changed in the scheduling, as I'm > on ubuntu's 2.6.24-19-generic x86_64 SMP (dual core), and I never saw > that happen. Yes, the Fedora kernels have a different ptrace implementation (based on utrace by Roland McGrath) which has more free but still permitted timing. > Would it be possible to add the thread to the thread list, in > addition to the lwp? IMO the reason for two lists is that really these two resources are different. You can perfectly have tracked LWPs with no corresponding thread structures. Attached a testcase using clone(2) which if you CTRL-C it has a state: (gdb) plist thread_list ptid $1 = {pid = 25112, lwp = 25112, tid = 0} (gdb) plist lwp_list ptid $2 = {pid = 25112, lwp = 25115, tid = 0} $3 = {pid = 25112, lwp = 25112, tid = 0} New thread notification will come from libthread_db but some time in between we have no corresponding thread structures such as they will never exist for standalone LWPs. Regards, Jan --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="clone-thread.c" Content-length: 1063 #include #include #include #include #include #include #include #define FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND \ | CLONE_THREAD | CLONE_SYSVSEM) static int child_func (void *arg) { sleep (60); _exit (EXIT_SUCCESS); abort (); } int main (void) { #ifndef PAGE_SIZE #define PAGE_SIZE 0x1000 #endif const size_t stack_size = PAGE_SIZE; unsigned char *stack = mmap (NULL, stack_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); int child_tid; assert (stack != NULL); assert (stack != MAP_FAILED); stack[0] = 0; stack[stack_size - 1] = 0; #ifdef __ia64__ extern int __clone2 (int (*fn) (void *arg), void *child_stack, size_t stack_size, int flags, void *arg); child_tid = __clone2 (child_func, stack + stack_size, stack_size, FLAGS, NULL); #else /* !__ia64__ */ child_tid = clone (child_func, stack + stack_size, FLAGS, NULL); #endif /* !__ia64__ */ sleep (60); return EXIT_SUCCESS; } --SLDf9lqlvOQaIe6s--