From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30225 invoked by alias); 23 Jan 2009 01:08:44 -0000 Received: (qmail 30216 invoked by uid 22791); 23 Jan 2009 01:08:43 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Jan 2009 01:08:39 +0000 Received: from zps76.corp.google.com (zps76.corp.google.com [172.25.146.76]) by smtp-out.google.com with ESMTP id n0N18abC008024 for ; Fri, 23 Jan 2009 01:08:36 GMT Received: from rv-out-0506.google.com (rvbf9.prod.google.com [10.140.82.9]) by zps76.corp.google.com with ESMTP id n0N18Kih008747 for ; Thu, 22 Jan 2009 17:08:32 -0800 Received: by rv-out-0506.google.com with SMTP id f9so168297rvb.6 for ; Thu, 22 Jan 2009 17:08:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.125.1 with SMTP id x1mr239817rvc.73.1232672912099; Thu, 22 Jan 2009 17:08:32 -0800 (PST) In-Reply-To: <200901221505.n0MF5MNB014404@d12av02.megacenter.de.ibm.com> References: <200901221505.n0MF5MNB014404@d12av02.megacenter.de.ibm.com> Date: Fri, 23 Jan 2009 01:08:00 -0000 Message-ID: Subject: Re: [rfa/gdbserver] Fix crash in thread_db_get_tls_address From: Doug Evans To: Ulrich Weigand Cc: gdb-patches@sourceware.org, drow@false.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00461.txt.bz2 On Thu, Jan 22, 2009 at 7:05 AM, Ulrich Weigand 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). > > 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 >