From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24275 invoked by alias); 17 Sep 2008 21:56:17 -0000 Received: (qmail 24230 invoked by uid 22791); 17 Sep 2008 21:56:16 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 17 Sep 2008 21:55:42 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m8HLrbVS009179; Wed, 17 Sep 2008 17:53:37 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m8HLrZEg012194; Wed, 17 Sep 2008 17:53:36 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m8HLrYDs029885; Wed, 17 Sep 2008 17:53:34 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.2) with ESMTP id m8HLrXD7026155; Wed, 17 Sep 2008 23:53:33 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id m8HLrWPw026152; Wed, 17 Sep 2008 23:53:32 +0200 Date: Wed, 17 Sep 2008 21:56:00 -0000 From: Jan Kratochvil To: Daniel Jacobowitz Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [patch] Fix a crash on NULL event_thread Message-ID: <20080917215332.GA25808@host0.dyn.jankratochvil.net> References: <20080912221227.GA5848@host0.dyn.jankratochvil.net> <20080917180337.GA10202@caradoc.them.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rS8CxjVDS/+yyDmU" Content-Disposition: inline In-Reply-To: <20080917180337.GA10202@caradoc.them.org> User-Agent: Mutt/1.5.18 (2008-05-17) 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: 2008-09/txt/msg00378.txt.bz2 --rS8CxjVDS/+yyDmU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 680 On Wed, 17 Sep 2008 20:03:37 +0200, Daniel Jacobowitz wrote: > Please move the reinit_frame_cache call so it is still right after > adjust_pc_after_break. I expect the only possible user is tui_selected_frame_level_changed_hook through DEPRECATED_SELECTED_FRAME_LEVEL_CHANGED_HOOK, thanks for catching it. > Also, no need to capitalize adjust_pc_after_break; this is like the texinfo > @var{} markup. You capitalize FOO when you mean "the value of a variable > named foo", but the name of the variable is still "foo". Thanks, I though it has different rules. > Otherwise looks OK, thanks. Committed the attached patch (added there two dependency comments). Regards, Jan --rS8CxjVDS/+yyDmU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="ecs4-cvs.patch" Content-length: 2017 2008-09-17 Jan Kratochvil Fix a crash on uninitialized ECS->EVENT_THREAD for a newly found thread. * infrun.c (wait_for_inferior): Move this ECS->EVENT_THREAD initialization ... (fetch_inferior_event): ... and this ECS->EVENT_THREAD initialization ... (handle_inferior_event): ... here after the add_thread call together with the local adjust_pc_after_break and reinit_frame_cache calls. =================================================================== RCS file: /cvs/src/src/gdb/infrun.c,v retrieving revision 1.318 retrieving revision 1.319 diff -u -r1.318 -r1.319 --- src/gdb/infrun.c 2008/09/11 14:21:49 1.318 +++ src/gdb/infrun.c 2008/09/17 21:48:49 1.319 @@ -1568,8 +1568,6 @@ else ecs->ptid = target_wait (waiton_ptid, &ecs->ws); - ecs->event_thread = find_thread_pid (ecs->ptid); - if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD) { xfree (ecs->ws.value.execd_pathname); @@ -1645,8 +1643,6 @@ thread. */ context_switch (ecs->ptid); - ecs->event_thread = find_thread_pid (ecs->ptid); - /* Now figure out what to do with the result of the result. */ handle_inferior_event (ecs); @@ -1854,10 +1850,6 @@ /* Always clear state belonging to the previous time we stopped. */ stop_stack_dummy = 0; - adjust_pc_after_break (ecs); - - reinit_frame_cache (); - /* If it's a new process, add it to the thread database */ ecs->new_thread_event = (!ptid_equal (ecs->ptid, inferior_ptid) @@ -1868,6 +1860,14 @@ && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event) add_thread (ecs->ptid); + ecs->event_thread = find_thread_pid (ecs->ptid); + + /* Dependent on valid ECS->EVENT_THREAD. */ + adjust_pc_after_break (ecs); + + /* Dependent on the current PC value modified by adjust_pc_after_break. */ + reinit_frame_cache (); + if (ecs->ws.kind != TARGET_WAITKIND_IGNORE) { /* Mark the non-executing threads accordingly. */ --rS8CxjVDS/+yyDmU--