Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: gdb-patches@sourceware.org, drow@false.org, dje@google.com
Subject: [rfa/gdbserver] Updated: Fix crash in thread_db_get_tls_address
Date: Fri, 03 Apr 2009 18:07:00 -0000	[thread overview]
Message-ID: <200904031806.n33I6tjw016918@d12av02.megacenter.de.ibm.com> (raw)
In-Reply-To: <e394668d0901221708v511ba0bwe73031a621152bd8@mail.gmail.com> from "Doug Evans" at Jan 22, 2009 05:08:32 PM

Doug Evans wrote:
> On Thu, Jan 22, 2009 at 7:05 AM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> > Doug Evans wrote:
> >
> >> Hi.  I've run into similar situations with the thread layer not yet
> >> initialized.  One aspect of this patch is a bit confusing.  Maybe a
> >> comment is warranted.
> >>
> >> Returning -1 will cause server.c:handle_query to mark the packet as
> >> unknown which will in turn cause remote.c:packet_ok to mark the packet
> >> as disabled (on the gdb side).  How does the packet get re-enabled if
> >> the thread layer is later initialized?
> >
> > You're right -- I missed that.  I guess we need to report an error
> > instead of marking the packet as unknown.
> >
> > The following patch is changed to use TD_ERR ("generic error" seems to
> > be the best response -- I don't see a more specific code that would be
> > appropriate here).
> >
> > Retested on powerpc64-linux (64-bit / 32-bit) with local gdbserver.
> 
> I don't know if there's a better value to use here either.  Maybe
> TD_TLSDEFER, but I'm just guessing (and I don't know how portable it
> is).

TD_TLSDEFER doesn't seem to be available everywhere, and has a somewhat
different meaning, I think.  In any case, it doesn't really matter, as GDB
will currently throw a TLS_GENERIC_ERROR in remote.c no matter what error
code is returned ...

I've updated the patch to account for multi-process changes.
Retested on powerpc64-linux (64-bit / 32-bit) with local gdbserver.

Dan, is this OK for mainline?

Bye,
Ulrich


ChangeLog:

	* thread-db.c (thread_db_get_tls_address): Do not crash if
	called when thread layer is not yet initialized.


Index: src/gdb/gdbserver/thread-db.c
===================================================================
--- src.orig/gdb/gdbserver/thread-db.c
+++ src/gdb/gdbserver/thread-db.c
@@ -382,6 +382,10 @@ thread_db_get_tls_address (struct thread
   struct lwp_info *lwp;
   struct thread_info *saved_inferior;
 
+  /* If the thread layer is not (yet) initialized, fail.  */
+  if (!current_process()->all_symbols_looked_up)
+    return TD_ERR;
+
   lwp = get_thread_lwp (thread);
   if (!lwp->thread_known)
     find_one_thread (lwp->head.id);


-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


  reply	other threads:[~2009-04-03 18:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-21 22:57 [rfa/gdbserver] " Ulrich Weigand
2009-01-22  9:18 ` Doug Evans
2009-01-22 15:06   ` Ulrich Weigand
2009-01-23  1:08     ` Doug Evans
2009-04-03 18:07       ` Ulrich Weigand [this message]
2009-04-03 18:26         ` [rfa/gdbserver] Updated: " Pedro Alves
2009-04-03 19:20           ` Ulrich Weigand
2009-04-03 19:24             ` Pedro Alves
2009-04-03 20:17               ` Ulrich Weigand
2009-04-03 18:29         ` Daniel Jacobowitz

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=200904031806.n33I6tjw016918@d12av02.megacenter.de.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=dje@google.com \
    --cc=drow@false.org \
    --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