From: Chet Ramey <chet.ramey@case.edu>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: chet.ramey@case.edu, bug-readline@gnu.org,
gdb-patches@sourceware.org,
Sterling Augustine <saugustine@google.com>
Subject: Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.]
Date: Fri, 08 Jul 2011 16:03:00 -0000 [thread overview]
Message-ID: <4E17138D.9060701@case.edu> (raw)
In-Reply-To: <4E15A220.4030404@case.edu>
On 7/7/11 8:10 AM, I wrote:
>> I do not know if it is possible to code _rl_handle_signal in a way which uses
>> only the safe syscalls and only atomic operations on volatile data structures.
>> Anyway even if it would be possible I find such code very fragile and
>> I believe the signals should be always delayed through _rl_caught_signal.
>
> Ironically, I changed it to respond immediately to signals when in callback
> mode because of a bug you filed from gdb. When readline was reading input
> using rl_callback_read_char it did not respond quickly enough to SIGINT,
> and gdb didn't catch it. You will have to check and make sure the
> conditions have changed enough to make it acceptable to delay signal
> handling.
It occurs to me that this will not work unless I make changes to readline's
callback implementation. Currently readline installs its signal handlers
as part of the callback setup (rl_callback_handler_install ->
_rl_callback_newline). This results in a situation where readline's signal
handlers are active when the application has flow control. I imagine the
most likely scenario is that the application (gdb) is in a select() call
waiting for input when the signal arrives, readline sets a flag, and the
select call either restarts or returns -1/EINTR. Either way, gdb can't do
anything about it except guess.
The most straightforward solution would be to move the signal setup into
rl_callback_read_char, so readline's signal handlers are in place only
when readline has control. It's still important that the application
call rl_callback_handler_remove to restore the original signal handlers.
Once that's done, readline will not have to call signal handlers
synchronously when running in callback mode. Thoughts?
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
next prev parent reply other threads:[~2011-07-08 14:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 0:19 [PATCH] Make interrupting tab-completion safe Sterling Augustine
2011-06-12 12:12 ` Jan Kratochvil
2011-06-13 17:45 ` Sterling Augustine
2011-06-26 22:22 ` [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.] Jan Kratochvil
2011-06-27 16:03 ` Joel Brobecker
2011-06-29 21:49 ` Jan Kratochvil
2011-06-29 13:54 ` [Bug-readline] " Chet Ramey
2011-06-29 20:35 ` Jan Kratochvil
2011-06-30 14:38 ` Chet Ramey
2011-07-06 16:03 ` Jan Kratochvil
2011-07-06 16:07 ` Chet Ramey
2011-07-06 17:42 ` Jan Kratochvil
2011-07-07 13:40 ` Chet Ramey
2011-07-08 16:03 ` Chet Ramey [this message]
2011-10-19 20:30 ` Jan Kratochvil
2011-10-19 17:02 ` Jan Kratochvil
2011-10-19 17:51 ` Pedro Alves
2011-10-19 18:50 ` Chet Ramey
2011-07-11 18:53 ` [PATCH] Make interrupting tab-completion safe Sterling Augustine
2011-07-11 18:54 ` Jan Kratochvil
[not found] ` <CAEG7qUxFvEoJ-E2YsoFPL-tKoK4kD3-pKn-h31uUeXQoDD2Gaw@mail.gmail.com>
2011-07-12 15:59 ` [dwarf2_mark_helper patch] " Jan Kratochvil
2011-07-12 17:48 ` Sterling Augustine
2011-07-12 18:56 ` Jan Kratochvil
2011-07-12 21:18 ` [commit] " Jan Kratochvil
2011-07-12 21:42 ` Tom Tromey
2011-07-12 22:51 ` Jan Kratochvil
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=4E17138D.9060701@case.edu \
--to=chet.ramey@case.edu \
--cc=bug-readline@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=saugustine@google.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