From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Doug Evans <dje@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] Workaround for 10970, 12702, avoid calling waitpid
Date: Tue, 17 May 2011 22:08:00 -0000 [thread overview]
Message-ID: <20110517220751.GA14238@host1.jankratochvil.net> (raw)
In-Reply-To: <20110517181920.7EE51246196@ruffy.mtv.corp.google.com>
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 <jan.kratochvil@redhat.com>
* 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 <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <assert.h>
+#include <unistd.h>
+
+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 <http://www.gnu.org/licenses/>.
+
+# 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"
next prev parent reply other threads:[~2011-05-17 22:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 18:19 Doug Evans
2011-05-17 22:08 ` Jan Kratochvil [this message]
2011-05-18 17:13 ` Jan Kratochvil
2011-05-18 18:17 ` Pedro Alves
2011-05-18 18:53 ` Jan Kratochvil
2011-05-18 19:17 ` Pedro Alves
2011-05-18 19:32 ` Jan Kratochvil
2011-05-18 19:53 ` Pedro Alves
2011-05-18 22:21 ` Doug Evans
2011-05-27 17:04 ` Jan Kratochvil
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=20110517220751.GA14238@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=dje@google.com \
--cc=gdb-patches@sourceware.org \
/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: link
Be 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