public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Kevin Buettner <kevinb@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 6/7] QUIT processing w/ explicit throw for gdb_exception_forced_quit
Date: Thu, 3 Mar 2022 21:26:30 +0000	[thread overview]
Message-ID: <b2968110-5ce6-d38c-0b3b-2b529f40e001@palves.net> (raw)
In-Reply-To: <20220227000051.3336149-7-kevinb@redhat.com>

On 2022-02-27 00:00, Kevin Buettner wrote:
> --- a/gdb/tui/tui-io.c
> +++ b/gdb/tui/tui-io.c
> @@ -1259,6 +1259,10 @@ tui_getc (FILE *fp)
>      {
>        return tui_getc_1 (fp);
>      }
> +  catch (const gdb_exception_forced_quit &ex)
> +    {
> +      throw;
> +    }
>    catch (const gdb_exception &ex)
>      {
>        /* Just in case, don't ever let an exception escape to readline.

This one's incorrect.  Note the comment in the context above, and also the comment
at the top of the function:

/* Get a character from the command window.  This is called from the
   readline package.  */

static int
tui_getc (FILE *fp)
{
  try
    {
      return tui_getc_1 (fp);
    }
  catch (const gdb_exception &ex)
    {
      /* Just in case, don't ever let an exception escape to readline.
	 This shouldn't ever happen, but if it does, print the
	 exception instead of just crashing GDB.  */
      exception_print (gdb_stderr, ex);

      /* If we threw an exception, it's because we recognized the
	 character.  */
      return 0;
    }
}


we really must not let a C++ exception propagate out to readline.  It will kill gdb
in configurations/architectures that don't default to -fasynchronous-unwind-tables.

As the comment says, this try/catch here is really just in case, I don't
think it is reachable.  But if we want to make it right for quits too,
just in case, then I think we instead need to swallow the exception, and call
set_quit_flag() / set sync_quit_force_run.



I'll continue auditing, and may come back to the same patches...

  reply	other threads:[~2022-03-03 21:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-27  0:00 [PATCH v3 0/7] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner
2022-02-27  0:00 ` [PATCH v3 1/7] Introduce gdb_exception_forced_quit Kevin Buettner
2022-02-27  0:00 ` [PATCH v3 2/7] Handle gdb SIGTERM by throwing / catching gdb_exception_force_quit Kevin Buettner
2022-02-27  0:00 ` [PATCH v3 3/7] Catch gdb_exception_error instead of gdb_exception (in many places) Kevin Buettner
2022-03-03 21:11   ` Pedro Alves
2022-02-27  0:00 ` [PATCH v3 4/7] Python QUIT processing updates Kevin Buettner
2022-02-27  0:00 ` [PATCH v3 5/7] Guile " Kevin Buettner
2022-02-27  0:00 ` [PATCH v3 6/7] QUIT processing w/ explicit throw for gdb_exception_forced_quit Kevin Buettner
2022-03-03 21:26   ` Pedro Alves [this message]
2022-02-27  0:00 ` [PATCH v3 7/7] Handle QUIT processing in the scoped_switch_fork_info destructor Kevin Buettner
2022-07-20  1:53 ` [PATCH v3 0/7] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Simon Marchi
2023-01-05 13:35   ` Tom de Vries
2023-01-10 15:19     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2968110-5ce6-d38c-0b3b-2b529f40e001@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).