public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>, gdb-patches@sourceware.org
Subject: Re: exceptions.KeyboardInterrupt is thrown in gdb.base/random-signal.exp
Date: Wed, 25 Nov 2015 16:26:00 -0000	[thread overview]
Message-ID: <5655E141.7030503@redhat.com> (raw)
In-Reply-To: <86ziy2xdt7.fsf@gmail.com>

On 11/25/2015 04:07 PM, Yao Qi wrote:
> Hi,
> I am fixing a fail in gdb.base/random-signal.exp like this,
> 
> Continuing.^M
> PASS: gdb.base/random-signal.exp: continue
> ^CPython Exception <type 'exceptions.KeyboardInterrupt'> <type 'exceptions.KeyboardInterrupt'>: ^M
> FAIL: gdb.base/random-signal.exp: stop with control-c (timeout)
> 
> I only see this fail out of 15~20 runs each time.  Is it because GDB
> received SIGINT before async_handle_remote_sigint is installed?  so
> handle_sigint is still the SIGINT handler, set_quit_flag will call
> python stuff, and KeyboardInterrupt is raised as a result.
> 
> In the test, we've already been aware of that the signal handler isn't
> ready, so "Continuing" is consumed and ctrl-c is delayed in 500ms.
> 
> # For this to work we must be sure to consume the "Continuing."
> # message first, or GDB's signal handler may not be in place.
> after 500 {send_gdb "\003"}
> 
> After I read the tcl manul about "after", I feel the usage of "after"
> above isn't 100% correct.  As the manual says, the "after" command
> returns immediately, and the tcl command {send_gdb "\003"} will be
> executed 500 ms later.  It is an asynchronous flavour, but what we want is
> a synchronous operation, like this,
> 
> after 500
> send_gdb "\003"
> 
> with this change, I don't see the timeout fail again.  Is it a fix or a
> hack?
> 

Seems like a hack -- I don't see how that can make a difference.  In both
cases, we send \003 after 500ms.

The test sets a software watchpoint, and resumes the target.  That means
the program will be constantly single-stepping, and gdb will be evaluating
the watched expression at each single-step.  I'd suspect that the problem
is likely that while the program is stopped to evaluate the watched
expression, something is calling target_terminal_ours, which restores
handle_sigint as SIGINT handler.  Then somehow you're unlucky to manage to
ctrl-c at that exact time.  The fix in that case is likely to be to call
target_terminal_ours_for_output instead, which doesn't touch the SIGINT
handler.

Thanks,
Pedro Alves

  reply	other threads:[~2015-11-25 16:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 16:07 Yao Qi
2015-11-25 16:26 ` Pedro Alves [this message]
2015-11-25 17:16   ` Yao Qi
2015-12-01 17:15   ` Yao Qi
2015-12-03 12:47     ` Pedro Alves
2015-12-03 17:09       ` Yao Qi
2015-12-03 17: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=5655E141.7030503@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.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).