Re: RFC: next/finish/etc -vs- exceptions

Pedro Alves
2009-06-12T21:51:42Z

[Reviewing bits and pieces instead of the whole patch at once]

On Friday 12 June 2009 21:44:30, Tom Tromey wrote:
> +/* A continuation callback for until_next_command.  */
> +
> +static void
> +until_next_continuation (void *arg)
> +{
> +  struct thread_info *tp = arg;
> +  delete_longjmp_breakpoint (tp->num);

This is broken, in that there's no guarantee that TP is still a
valid pointer here.

> +}
> +
>  /* Proceed until we reach a different source line with pc greater than
>     our current one or exit the function.  We skip calls in both cases.
>
> @@ -1170,6 +1181,8 @@ until_next_command (int from_tty)
>    struct symbol *func;
>    struct symtab_and_line sal;
>    struct thread_info *tp = inferior_thread ();
> +  int thread = tp->num;
> +  struct cleanup *old_chain;
>
>    clear_proceed_status ();
>
> @@ -1205,7 +1218,18 @@ until_next_command (int from_tty)
>
>    tp->step_multi = 0;          /* Only one call to proceed */
>
> +  tp->initiating_frame = set_exception_breakpoint (frame);

> +  old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
> +
>    proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
> +
> +  if (target_can_async_p () && is_running (inferior_ptid))
> +    {
> +      discard_cleanups (old_chain);
> +      add_continuation (tp, until_next_continuation, tp, NULL);
> +    }
> +  else
> +    do_cleanups (old_chain);

In sync execution mode, between that `proceed' and this do_cleanups, a
lot happens. TP may exit, or the whole process for the matter.
So, after `proceed', any TP pointer is invalid. Any other code
doing the same thing is equally broken.

--
Pedro Alves