From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2745 invoked by alias); 22 Jan 2009 15:06:33 -0000 Received: (qmail 2737 invoked by uid 22791); 22 Jan 2009 15:06:32 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate5.de.ibm.com (HELO mtagate5.de.ibm.com) (195.212.29.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Jan 2009 15:06:22 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.8/8.13.8) with ESMTP id n0MF5NP0568200 for ; Thu, 22 Jan 2009 15:05:23 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0MF5MIJ2580728 for ; Thu, 22 Jan 2009 16:05:22 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0MF5M4g014410 for ; Thu, 22 Jan 2009 16:05:22 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id n0MF5MNB014404; Thu, 22 Jan 2009 16:05:22 +0100 Message-Id: <200901221505.n0MF5MNB014404@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 22 Jan 2009 16:05:22 +0100 Subject: Re: [rfa/gdbserver] Fix crash in thread_db_get_tls_address To: dje@google.com (Doug Evans) Date: Thu, 22 Jan 2009 15:06:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org, drow@false.org In-Reply-To: from "Doug Evans" at Jan 22, 2009 01:18:21 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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/msg00449.txt.bz2 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