From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96242 invoked by alias); 19 Jul 2017 02:16:38 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 95839 invoked by uid 89); 19 Jul 2017 02:16:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=mar, century, Mar X-HELO: limerock03.mail.cornell.edu Received: from limerock03.mail.cornell.edu (HELO limerock03.mail.cornell.edu) (128.84.13.243) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Jul 2017 02:16:32 +0000 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite3.serverfarm.cornell.edu [10.16.197.8]) by limerock03.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id v6J2GUF2025355 for ; Tue, 18 Jul 2017 22:16:30 -0400 Received: from [192.168.0.4] (mta-68-175-129-7.twcny.rr.com [68.175.129.7] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id v6J2GSkI010282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 18 Jul 2017 22:16:29 -0400 Subject: Re: fflush(NULL) clobbers input streams To: cygwin-apps@cygwin.com References: <87k2376jck.fsf@Rainer.invalid> <20170718095456.GC26902@calimero.vinschen.de> <20170718105109.GD26902@calimero.vinschen.de> <87fudtlfen.fsf@Rainer.invalid> From: Ken Brown Message-ID: <8daea64f-4f36-72cc-13f2-75c64ab06ad6@cornell.edu> Date: Wed, 19 Jul 2017 02:16:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Cornell-Gauge: Gauge=XXXXX X-PMX-CORNELL-AUTH-RESULTS: dkim-out=none; X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00047.txt.bz2 On 7/18/2017 6:41 PM, Ken Brown wrote: > On 7/18/2017 3:21 PM, Achim Gratz wrote: >> Corinna Vinschen writes: >>> Oh, and a plain C testcase, of course... >> >> Call that fflush.c: >> >> --8<---------------cut here---------------start------------->8--- >> #include >> int >> main(int argc, char **argv) >> { >> char buf[1024]; >> int i; >> char *bp = buf; >> while (1) { >> while ((i = getc(stdin)) != -1 >> && (*bp++ = i) != '\n' >> && bp < &buf[1024]) >> /* DO NOTHING */ ; >> *bp = '\0'; >> fprintf(stdout, "%s", buf); >> fflush(NULL); >> if (i == -1) >> return 0; >> bp = buf; >> } >> } >> --8<---------------cut here---------------end--------------->8--- >> >> Then run: >> >> gcc fflush.c -o fflush >> cat fflush.c | ./fflush 2>/dev/null > fflush.out >> diff fflush.c fflush.out >> >> If things are working, fflush.c and fflush.out should be identical. >> Currently only the first line makes it into fflush.out on Cygwin. > > I've checked that the 2017-03-08 snapshot is good and the 2017-03-10 > snapshot is bad. I'll bisect further when I get a chance Done: 44b1746a41921533d27aca414a9188314cb725b6 is the first bad commit commit 44b1746a41921533d27aca414a9188314cb725b6 Author: Corinna Vinschen Date: Fri Mar 10 20:21:09 2017 +0100 errno: Stop using _impure_ptr->_errno completely We use errno AKA _REENT->_errno since the last century and only set _impure_ptr->_errno for backward compat. Stop that. Also, remove the last check for _impure_ptr->_errno in Cygwin code. Ken