From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7757 invoked by alias); 27 May 2010 21:20:59 -0000 Received: (qmail 7748 invoked by uid 22791); 27 May 2010 21:20:59 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 May 2010 21:20:51 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4RLKgd5020386 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 May 2010 17:20:42 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4RLKdc5032373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 May 2010 17:20:41 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o4RLKceM025929; Thu, 27 May 2010 23:20:38 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o4RLKbEP025928; Thu, 27 May 2010 23:20:37 +0200 Date: Thu, 27 May 2010 21:24:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [patch] Fix crash on /proc/PID/stat race Message-ID: <20100527212037.GA24735@host0.dyn.jankratochvil.net> References: <20100527175404.GA16087@host0.dyn.jankratochvil.net> <201005272000.26518.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201005272000.26518.pedro@codesourcery.com> User-Agent: Mutt/1.5.20 (2009-12-10) 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: 2010-05/txt/msg00666.txt.bz2 On Thu, 27 May 2010 21:00:26 +0200, Pedro Alves wrote: > Why are we trying to get at the core if we know the process > is gone? Since the process is already waited for, I'm surprised > the fopen succeeded in the first place. On a couple of quick tests, > I always see fopen failing. It sounds like a kernel bug. Can't we > just skip the core_of_thread call for > TARGET_WAITKING_EXITED|TARGET_WAITKING_SIGNALLED? An additional patch like this one? It is IMO not correct for GDB to crash on unexpected /proc/** content. Thanks, Jan 2010-05-27 Jan Kratochvil (maybe rather Pedro Alves as I just "installed" it) * linux-nat.c (linux_nat_wait_1): Do not call linux_nat_core_of_thread_1 on TARGET_WAITKIND_EXITED or TARGET_WAITKIND_SIGNALLED. --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3626,7 +3626,13 @@ retry: fprintf_unfiltered (gdb_stdlog, "LLW: exit\n"); restore_child_signals_mask (&prev_mask); - lp->core = linux_nat_core_of_thread_1 (lp->ptid); + + if (ourstatus->kind == TARGET_WAITKIND_EXITED + || ourstatus->kind == TARGET_WAITKIND_SIGNALLED) + lp->core = -1; + else + lp->core = linux_nat_core_of_thread_1 (lp->ptid); + return lp->ptid; }