From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16217 invoked by alias); 7 Jul 2011 12:10:40 -0000 Received: (qmail 16192 invoked by uid 22791); 7 Jul 2011 12:10:34 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mpv2.tis.CWRU.Edu (HELO mpv2.tis.cwru.edu) (129.22.105.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jul 2011 12:10:10 +0000 Received: from mpv5.cwru.edu (mpv5.tis.CWRU.Edu [129.22.105.51]) by mpv2.tis.cwru.edu (MOS 4.2.3-GA) with ESMTP id BAN99113; Thu, 7 Jul 2011 08:10:08 -0400 Received: from caleb.INS.CWRU.Edu (caleb.INS.CWRU.Edu [129.22.8.211]) by mpv5.cwru.edu (MOS 4.2.3-GA) with ESMTP id AGD54601 (AUTH cpr); Thu, 7 Jul 2011 08:10:12 -0400 Message-ID: <4E15A220.4030404@case.edu> Date: Thu, 07 Jul 2011 13:40:00 -0000 From: Chet Ramey Reply-To: chet.ramey@case.edu User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: Jan Kratochvil CC: bug-readline@gnu.org, gdb-patches@sourceware.org, Sterling Augustine , chet.ramey@case.edu Subject: Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.] References: <20110612121158.GA10611@host1.jankratochvil.net> <20110626222146.GA4410@host1.jankratochvil.net> <4E0B2E83.9030202@case.edu> <20110629203457.GA28353@host1.jankratochvil.net> <4E0C8A5D.7000807@case.edu> <20110706154621.GA17142@host1.jankratochvil.net> <110706155826.AA07325.SM@caleb.INS.CWRU.Edu> <20110706164400.GA31447@host1.jankratochvil.net> In-Reply-To: <20110706164400.GA31447@host1.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A020209.4E15A220.0173,ss=1,fgs=0, ip=0.0.0.0, so=2010-12-23 16:51:53, dmn=2009-09-10 00:05:08, mode=single engine Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-07/txt/msg00234.txt.bz2 On 7/6/11 12:44 PM, Jan Kratochvil wrote: > On Wed, 06 Jul 2011 17:58:26 +0200, Chet Ramey wrote: >> As I said, I'm willing to remove these references and see what happens. Since >> you have a way to readily reproduce the problem, I was hoping you'd do it >> and let me know what you found. > > I do not think any testing matters here. This is a difficult to reproduce > race + memory corruption. While a crash proves it is wrong no crash does not > prove anything. The impression I got from your earlier message is that is is very easy to reproduce using a GDB .exp file: "Used this GDB .exp file, reproducible in several seconds" All I am asking you do to is to check whether you can reproduce it using the same .exp file after removing references to _rl_interrupt_immediately in complete.c. > > Even if no existing system ever crashes the code is still wrong because it > violates POSIX: > http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html > The following table defines a set of functions that shall be either > reentrant or non-interruptible by signals and shall be async-signal-safe. > > Static code analysis is the only valid verification. Currently the signal > code calls free() which is not listed in the safe syscalls list above, > therefore the code is not correct. > > 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. 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/