[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal h
Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.]
Fri, 08 Jul 2011 10:26:21 -0400
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:126.96.36.199) Gecko/20110616 Thunderbird/3.1.11
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
>> 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
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?
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/