From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17395 invoked by alias); 6 Jul 2011 17:32:52 -0000 Received: (qmail 17386 invoked by uid 22791); 6 Jul 2011 17:32:51 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 06 Jul 2011 17:32:34 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p66HVlME014886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Jul 2011 13:32:32 -0400 Received: from host1.jankratochvil.net (ovpn-113-91.phx2.redhat.com [10.3.113.91]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p66Gi2eP030616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 6 Jul 2011 12:44:04 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p66Gi1kA032411; Wed, 6 Jul 2011 18:44:01 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p66Gi0fK032390; Wed, 6 Jul 2011 18:44:00 +0200 Date: Wed, 06 Jul 2011 17:42:00 -0000 From: Jan Kratochvil To: Chet Ramey Cc: bug-readline@gnu.org, gdb-patches@sourceware.org, saugustine@google.com, chet@po.cwru.edu Subject: Re: [Bug-readline] [readline patch, gdb-7.3?] Avoid free from a signal handler [Re: [PATCH] Make interrupting tab-completion safe.] Message-ID: <20110706164400.GA31447@host1.jankratochvil.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <110706155826.AA07325.SM@caleb.INS.CWRU.Edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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/msg00206.txt.bz2 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. 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. Sure it then has to depend on the application which should properly return to readline callers immediately if it sees any EINTR. Thanks, Jan