From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4125 invoked by alias); 17 May 2011 22:08:16 -0000 Received: (qmail 4115 invoked by uid 22791); 17 May 2011 22:08:15 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,FUZZY_AMBIEN,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 May 2011 22:07:55 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4HM7tkq029185 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 May 2011 18:07:55 -0400 Received: from host1.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4HM7rYv009784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 17 May 2011 18:07:55 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p4HM7qvn017446; Wed, 18 May 2011 00:07:52 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p4HM7q2S017440; Wed, 18 May 2011 00:07:52 +0200 Date: Tue, 17 May 2011 22:08:00 -0000 From: Jan Kratochvil To: Doug Evans Cc: gdb-patches@sourceware.org Subject: Re: [patch] Workaround for 10970, 12702, avoid calling waitpid Message-ID: <20110517220751.GA14238@host1.jankratochvil.net> References: <20110517181920.7EE51246196@ruffy.mtv.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110517181920.7EE51246196@ruffy.mtv.corp.google.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-05/txt/msg00396.txt.bz2 On Tue, 17 May 2011 20:19:20 +0200, Doug Evans wrote: > A proper fix seems much more invasive, Which proper fix do you mean? I guess __WNOTHREAD should be enough but it does not work, it may be a kernel Bug. Filed for evaluation: ptrace: __WNOTHREAD does not work https://bugzilla.redhat.com/show_bug.cgi?id=705583 If it is a kernel Bug another issue is how it could be made backward compatible with existing kernels and whether such fix should be in FSF GDB. Wouldn't a non-racy backward fix be possible using blocked SIGCHLD, sigsuspend and WNOHANG? BTW the Fedora patch also changed linux_xfer_partial: /* nptl_db expects being able to transfer memory just by specifying PID. After the thread group leader exists the Linux kernel turns the task into zombie no longer permitting accesses to its memory. Transfer the memory from an arbitrary LWP_LIST entry in such case. */ which no longer seems to be needed, I guess due to Pedro's fix proving: 2008-07-10 85fdbde9dfc62928a36ece6c53a42b59e28b31e7 Non-stop linux native. /* Access an lwp we know is stopped. */ info->proc_handle.ptid = ptid; while the fix by me was written before - 2007-07-07. > and this works well enough for a large number of cases. Providing fixed testcase but it does not work as it already exploits the race in the fix. > I'll be checking it in tomorrow if there are no objections. I am against checking in racy code which can be hopefully fixed properly. Thanks, Jan testsuite/ 2011-05-17 Jan Kratochvil * gdb.threads/leader-exit.c: New file. * gdb.threads/leader-exit.exp: New file. --- /dev/null +++ b/gdb/testsuite/gdb.threads/leader-exit.c @@ -0,0 +1,49 @@ +/* Clean exit of the thread group leader should not break GDB. + + Copyright 2007, 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include +#include + +static volatile pthread_t main_thread; + +static void * +start (void *arg) +{ + int i; + + i = pthread_join (main_thread, NULL); + assert (i == 0); + + return arg; /* break-here */ +} + +int +main (void) +{ + pthread_t thread; + int i; + + main_thread = pthread_self (); + + i = pthread_create (&thread, NULL, start, NULL); + assert (i == 0); + + pthread_exit (NULL); + /* NOTREACHED */ + return 0; +} --- /dev/null +++ b/gdb/testsuite/gdb.threads/leader-exit.exp @@ -0,0 +1,38 @@ +# Copyright (C) 2007, 2011 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Exit of the thread group leader should not break GDB. + +set testfile "leader-exit" +set srcfile ${testfile}.c +set executable ${testfile} +set binfile ${objdir}/${subdir}/${executable} + +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + return -1 +} + +clean_restart ${executable} + +if ![runto_main] { + return -1 +} + +gdb_breakpoint [gdb_get_line_number "break-here"] +gdb_continue_to_breakpoint "break-here" ".* break-here .*" + +gdb_test "info threads" \ + "\r\n\[ \t\]*Id\[ \t\]+Target\[ \t\]+Id\[ \t\]+Frame\[ \t\]*\r\n\\* 2 *Thread \[^\r\n\]* at \[^\r\n\]*" \ + "Single thread has been left"