From: ppluzhnikov@google.com (Paul Pluzhnikov)
To: gdb-patches@sourceware.org
Cc: ppluzhnikov@google.com
Subject: [patch] Fix for PR gdb/10838
Date: Thu, 12 Nov 2009 00:35:00 -0000 [thread overview]
Message-ID: <20091112003504.29C4876D6F@ppluzhnikov.mtv.corp.google.com> (raw)
Greetings,
In http://sourceware.org/bugzilla/show_bug.cgi?id=10838
gdb attach; detach; attach sequence leaves libpthread in hosed state.
The root cause turned out to be that this:
td_event_emptyset (&events);
info->td_ta_set_event_p (info->thread_agent, &events);
is a no-op -- glibc ORs new event bits in, but doesn't clear any already
set bits. To clear them, one must call td_ta_clear_event() instead.
Here is a patch which fixes this in gdb and gdbserver.
Tested (GDB only) on Linux/x86_64 with no regressions.
Thanks,
--
Paul Pluzhnikov
gdb/ChangeLog:
2009-11-11 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/10838
* linux-thread-db.c (thread_db_info): New member.
(disable_thread_event_reporting): Call td_ta_clear_event.
gdbserver/ChangeLog:
2009-11-11 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/10838
* thread-db.c (thread_db_free): Call td_ta_clear_event.
Index: linux-thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-thread-db.c,v
retrieving revision 1.67
diff -u -p -u -r1.67 linux-thread-db.c
--- linux-thread-db.c 3 Nov 2009 17:14:56 -0000 1.67
+++ linux-thread-db.c 12 Nov 2009 00:21:02 -0000
@@ -141,6 +141,8 @@ struct thread_db_info
td_event_e event, td_notify_t *ptr);
td_err_e (*td_ta_set_event_p) (const td_thragent_t *ta,
td_thr_events_t *event);
+ td_err_e (*td_ta_clear_event_p) (const td_thragent_t *ta,
+ td_thr_events_t *event);
td_err_e (*td_ta_event_getmsg_p) (const td_thragent_t *ta,
td_event_msg_t *msg);
@@ -701,6 +703,7 @@ try_thread_db_load_1 (struct thread_db_i
/* These are not essential. */
info->td_ta_event_addr_p = dlsym (info->handle, "td_ta_event_addr");
info->td_ta_set_event_p = dlsym (info->handle, "td_ta_set_event");
+ info->td_ta_clear_event_p = dlsym (info->handle, "td_ta_clear_event");
info->td_ta_event_getmsg_p = dlsym (info->handle, "td_ta_event_getmsg");
info->td_thr_event_enable_p = dlsym (info->handle, "td_thr_event_enable");
info->td_thr_tls_get_addr_p = dlsym (info->handle, "td_thr_tls_get_addr");
@@ -907,14 +910,14 @@ thread_db_load (void)
static void
disable_thread_event_reporting (struct thread_db_info *info)
{
- if (info->td_ta_set_event_p != NULL)
+ if (info->td_ta_clear_event_p != NULL)
{
td_thr_events_t events;
/* Set the process wide mask saying we aren't interested in any
events anymore. */
- td_event_emptyset (&events);
- info->td_ta_set_event_p (info->thread_agent, &events);
+ td_event_fillset (&events);
+ info->td_ta_clear_event_p (info->thread_agent, &events);
}
info->td_create_bp_addr = 0;
Index: gdbserver/thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/thread-db.c,v
retrieving revision 1.26
diff -u -p -u -r1.26 thread-db.c
--- gdbserver/thread-db.c 29 Oct 2009 17:43:44 -0000 1.26
+++ gdbserver/thread-db.c 12 Nov 2009 00:21:02 -0000
@@ -759,6 +759,19 @@ thread_db_free (struct process_info *pro
{
#ifndef USE_LIBTHREAD_DB_DIRECTLY
td_err_e (*td_ta_delete_p) (td_thragent_t *);
+ td_err_e (*td_ta_clear_event_p) (const td_thragent_t *ta,
+ td_thr_events_t *event);
+
+ td_ta_clear_event_p = dlsym (thread_db->handle, "td_ta_clear_event");
+ if (td_ta_clear_event_p != NULL)
+ {
+ td_thr_events_t events;
+
+ /* Set the process wide mask saying we aren't interested in any
+ events anymore. */
+ td_event_fillset (&events);
+ (*td_ta_clear_event_p) (thread_db->thread_agent, &events);
+ }
td_ta_delete_p = dlsym (thread_db->handle, "td_ta_delete");
if (td_ta_delete_p != NULL)
@@ -766,6 +779,10 @@ thread_db_free (struct process_info *pro
dlclose (thread_db->handle);
#else
+ td_thd_events_t events;
+
+ td_event_fillset (&events);
+ td_ta_clear_event (thread_db->thread_agent, &events);
td_ta_delete (thread_db->thread_agent);
#endif /* USE_LIBTHREAD_DB_DIRECTLY */
next reply other threads:[~2009-11-12 0:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 0:35 Paul Pluzhnikov [this message]
2009-11-12 0:43 ` Daniel Jacobowitz
2009-11-12 0:48 ` Paul Pluzhnikov
2009-11-14 2:04 ` Paul Pluzhnikov
2009-11-15 17:37 ` Daniel Jacobowitz
2009-11-15 17:43 ` Doug Evans
2009-11-15 17:47 ` Daniel Jacobowitz
2009-11-16 15:11 ` Pedro Alves
2009-11-16 15:14 ` Pedro Alves
2009-11-16 16:05 ` Paul Pluzhnikov
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=20091112003504.29C4876D6F@ppluzhnikov.mtv.corp.google.com \
--to=ppluzhnikov@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