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 v2 4/6] Python QUIT processing updates
Date: Mon, 27 Sep 2021 19:24:51 +0100	[thread overview]
Message-ID: <764a5dcc-4391-ead3-61c1-82359ff80bf7@palves.net> (raw)
In-Reply-To: <20210822231959.184061-5-kevinb@redhat.com>

On 2021-08-23 12:20 a.m., Kevin Buettner via Gdb-patches wrote:
> See the previous patch in this series for the motivation behind these
> updates.
> 
> This commit contains updates to Python's QUIT handling.  Specifically,
> it makes sure that a SIGTERM sent to GDB will be propagated to the top
> level.  While there are instances where we want to allow python code
> to catch Ctrl-C / SIGINT (and possibly) swallow it, I don't think we
> want that behavior for SIGTERM.  Therefore, there are cases where
> sync_quit_force_run is checked explicitly.  In other cases, I
> was able to defer the decision to GDB_PY_HANDLE_EXCEPTION.  (My goal
> was to minimize explicit references to sync_quit_force_run.)

Something to ponder about is whether having a distinct gdb_exception_sigterm
would be cleaner.

> ---
>  gdb/python/py-finishbreakpoint.c |  6 ++++--
>  gdb/python/py-gdb-readline.c     | 12 ++++++++----
>  gdb/python/py-symbol.c           |  4 ++++
>  gdb/python/py-utils.c            |  4 +++-
>  gdb/python/py-value.c            |  4 ++++
>  5 files changed, 23 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
> index 1d8373d807e..120e40db6eb 100644
> --- a/gdb/python/py-finishbreakpoint.c
> +++ b/gdb/python/py-finishbreakpoint.c
> @@ -270,8 +270,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
>      }
>    catch (const gdb_exception &except)
>      {
> -      /* Just swallow.  Either the return type or the function value
> -	 remain NULL.  */
> +      /* Swallow everything except for a SIGTERM sent to GDB.  Either the
> +         return type or the function value remain NULL.  */
> +      if (sync_quit_force_run)
> +	throw;

AFAIK, it is not safe to let C++ exceptions cross the Python runtime, as Python
is written in C.  The issue may be papered over on x86-64 Linux and there
everything is built with -fasynchronous-unwind-tables.  Even if it looks like
it works, Python doesn't see the exception at all so isn't given a chance to
properly cleanup as the exception unwinds the stack.

The same concern applies to the rest of the patch.

  reply	other threads:[~2021-09-27 18:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 23:19 [PATCH v2 0/6] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner
2021-08-22 23:19 ` [PATCH v2 1/6] Handle recursive internal problem in gdb_internal_error_resync Kevin Buettner
2021-09-27 17:38   ` Pedro Alves
2022-02-26 20:40     ` Kevin Buettner
2021-08-22 23:19 ` [PATCH v2 2/6] Handle gdb SIGTERM via normal QUIT processing Kevin Buettner
2021-09-27 17:39   ` Pedro Alves
2021-08-22 23:20 ` [PATCH v2 3/6] Catch and (re)throw gdb_exception_quit Kevin Buettner
2021-09-27 18:05   ` Pedro Alves
2021-08-22 23:20 ` [PATCH v2 4/6] Python QUIT processing updates Kevin Buettner
2021-09-27 18:24   ` Pedro Alves [this message]
2021-08-22 23:20 ` [PATCH v2 5/6] Guile " Kevin Buettner
2021-09-27 18:26   ` Pedro Alves
2021-08-22 23:20 ` [PATCH v2 6/6] QUIT processing w/ explicit sync_quit_force_run check Kevin Buettner
2021-09-27 18:34   ` Pedro Alves
2021-09-27 17:20 ` [PATCH v2 0/6] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner

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=764a5dcc-4391-ead3-61c1-82359ff80bf7@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).