This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix a crash on NULL event_thread


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
2008-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	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.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]