[rfa/gdbserver] Updated: Fix crash in thread_db_get_tls_address

Pedro Alves pedro@codesourcery.com
Fri Apr 3 18:26:00 GMT 2009


On Friday 03 April 2009 19:06:55, Ulrich Weigand wrote:
> 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;
> +

(note the missing space after current_process)

The qGetTLSAddr packet takes an explicit thread id, so in this
case, it may be that the current process isn't the
correct one.  I think in this case the best would be to
inferior.c:get_thread_process and use that, like:

  if (!get_thread_process (thread)->all_symbols_looked_up)
    return TD_ERR;

Alternatively you could make sure you call current_process (),
after temporarily   having switched the current inferior, like
we do a bit below.

Sorry for the extra work...

-- 
Pedro Alves



More information about the Gdb-patches mailing list