Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.]

Chet Ramey
2011-06-30T14:38:50Z

On 6/29/11 4:34 PM, Jan Kratochvil wrote:
> On Wed, 29 Jun 2011 15:54:11 +0200, Chet Ramey wrote:
>> If you feel that you need to make this change for the current version of
>> gdb, go ahead.
>
> OK. It is not a complete fix but hopefully the one people hit the most.
> I have also seen unreproducible crash(es) on a completion CTRL-C myself.
>
>
>> The big problem is to allow operations that read through the file system
>> (like completion) to be interrupted without running unsafe functions from
>> a signal handler.
>
> I do not see the problem, readline already does not use SA_RESTART and the
> application also gets SIGINT passed by _rl_handle_signal so it aborts the
> completion reading on its own, as GDB does by the QUIT macro.
>
>
>> It does the user no good to keep setting the "I got SIGINT" flag if he's
>> trying to complete files on a dead or otherwise unreachable file server.
>
> The syscall should get EINTR without SA_RESTART. But I admit I may not see
> the problem now.

I have seen cases where the user hits ^C while readline or a filename
completion function is attempting to traverse a file system on a dead
NFS server, the signal handler gets hit, but the system call doesn't
get interrupted. I haven't seen those cases in a while, though.

Let's try this. Instead of introducing a leak in free(), remove the
references to _rl_interrupt_immediately in complete.c. Those are the
only two places where the interrupt handler is called synchronously.
I have a couple more changes to make if that doesn't provide the
necessary responsiveness.

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/