This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfa/gdbserver] Fix crash in thread_db_get_tls_address
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: dje at google dot com (Doug Evans)
- Cc: gdb-patches at sourceware dot org, drow at false dot org
- Date: Thu, 22 Jan 2009 16:05:22 +0100 (CET)
- Subject: Re: [rfa/gdbserver] Fix crash in thread_db_get_tls_address
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.
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
@@ -388,6 +388,10 @@ thread_db_get_tls_address (struct thread
td_err_e err;
struct process_info *process;
+ /* If the thread layer is not (yet) initialized, fail. */
+ if (!all_symbols_looked_up)
+ return TD_ERR;
+
process = get_thread_process (thread);
if (!process->thread_known)
find_one_thread (process->lwpid);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com