From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7937 invoked by alias); 2 Jul 2011 16:59:23 -0000 Received: (qmail 7928 invoked by uid 22791); 2 Jul 2011 16:59:22 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 02 Jul 2011 16:59:08 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id p62Gwpue031548; Sat, 2 Jul 2011 18:58:51 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id p62GwoWV017449; Sat, 2 Jul 2011 18:58:50 +0200 (CEST) Date: Sat, 02 Jul 2011 16:59:00 -0000 Message-Id: <201107021658.p62GwoWV017449@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: brobecker@adacore.com CC: gdb-patches@sourceware.org, brobecker@adacore.com In-reply-to: <1309547006-21412-3-git-send-email-brobecker@adacore.com> (message from Joel Brobecker on Fri, 1 Jul 2011 12:03:24 -0700) Subject: Re: [Darwin 2/4] Do not crash (failed assertion) after PT_KILL ptrace error References: <1309547006-21412-1-git-send-email-brobecker@adacore.com> <1309547006-21412-3-git-send-email-brobecker@adacore.com> 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: 2011-07/txt/msg00069.txt.bz2 > From: Joel Brobecker > Date: Fri, 1 Jul 2011 12:03:24 -0700 > > This is something I noticed while reading the code. Putting an > assertion that the PT_KILL ptrace call never returns an error > is too strong. It might not be a debugger bug that caused the > PT_KILL ptrace operation to fail, so a failed-assertion "crash" > would not be justified. It also seems easy enough to continue > and get ready for the next debugging session. So this patch > changes the assertion into a warning. > > This patch also tries to handle the case where ptrace return -1, > but left errno set to zero. According to the ptrace man page, > it is possible for some ptrace operations to return -1 in non-error > situations, and to detect those situations, it explains that errno > should be set prior to calling ptrace, and then checked again after. I think I disagree here. PT_KILL should only fail if you pass it the wrong process ID. So unless there is an OS bug of some sorts, this is going to be a GDB internal error. Do you have actual evidence there is a kernel bug here? > gdb/ChangeLog: > > * darwin-nat.c (darwin_ptrace): Add documentation. > Set errno to zero before calling ptrace. If ptrace returns > -1 and errno is zero, then change then return zero. > (darwin_kill_inferior): Issue a warning instead of triggering > a failed assertion when the PT_KILL ptrace operations returned > nonzero.