From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6476 invoked by alias); 23 Jun 2009 16:18:43 -0000 Received: (qmail 6461 invoked by uid 22791); 23 Jun 2009 16:18:42 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Jun 2009 16:18:31 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.2/jtpda-5.5pre1) with ESMTP id n5NGIOPr038928 ; Tue, 23 Jun 2009 18:18:24 +0200 (CEST) Received: from mailserver.u-strasbg.fr (ms1.u-strasbg.fr [IPv6:2001:660:2402:d::10]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id n5NGIOSU090997 ; Tue, 23 Jun 2009 18:18:24 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) Received: from d620muller (www-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id n5NGIOFP000797 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Tue, 23 Jun 2009 18:18:24 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) From: "Pierre Muller" To: Cc: "'Pedro Alves'" Subject: [RFA] Fix gdbserver crash if using kill in remote connection to windows gdbserver Date: Tue, 23 Jun 2009 16:18:00 -0000 Message-ID: <003001c9f41e$3a294830$ae7bd890$@u-strasbg.fr> 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-06/txt/msg00610.txt.bz2 I wanted to test Doug Evans patch for hardware watchpoint support for i386 gdbserver but ran into a new crash for gdbserver in the testsuite. GDB uses an internal fake pid (42000) for remote targets not supporting multi-processes, but send this fake pid to gdbserver when kill command is used with remote target. This made win32-low look for a inferior of pid 42000, which does not exist and created a crash in remove_process that was called with a NULL argument. This fixes win32 target, but there might be other targets that suffer from the same problem... Pedro, could you check this? Is this patch OK? Pierre Muller Pascal language support maintainer for GDB 2009-06-23 Pierre Muller * win32-low.c (win32_kill): Use current_process_id to find process to remove as long as multi_process is zero. (win32_detach): Idem. Index: src/gdb/gdbserver/win32-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.36 diff -u -p -r1.36 win32-low.c --- src/gdb/gdbserver/win32-low.c 22 Jun 2009 19:33:41 -0000 1.36 +++ src/gdb/gdbserver/win32-low.c 23 Jun 2009 16:11:01 -0000 @@ -675,7 +675,12 @@ win32_kill (int pid) win32_clear_inferiors (); - process = find_process_pid (pid); + /* GDB used a fake pid of 42000 for targets that don't support multi_process + yet. */ + if (multi_process) + process = find_process_pid (pid); + else + process = find_process_pid (current_process_id); remove_process (process); return 0; } @@ -711,7 +716,12 @@ win32_detach (int pid) return -1; DebugSetProcessKillOnExit (FALSE); - process = find_process_pid (pid); + /* GDB used a fake pid of 42000 for targets that don't support multi_process + yet. */ + if (multi_process) + process = find_process_pid (pid); + else + process = find_process_pid (current_process_id); remove_process (process); win32_clear_inferiors ();