From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E74F51F462 for ; Wed, 19 Jun 2019 13:10:22 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=WH60f 8T/OwQyBNrZKUI2MzLhBxmo/z5AmvlwcCnj5ke6B1anZuofvzwoW00PLx1uxhhvT 4vf0H1Cavj4nZUmNCqdUIqNMFZzLZ1ys3h2nEHcP+iXCcUPAYFs4Ji0TNCY+ECta wjOSS3Uzr+WiUNeYEb05nVwzsG2HV/SIr4kzT0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=/T+qp3uodEf yIfJd6IisXI0UBeg=; b=Yt9cf/U/V8s8MV9NQfMB2DkkT9KQK0MiGBIXxxLaHct vyvrzxs4GgbfgmghsD68/E0ipS150beCisT4UeFiVGKZ4pqvn0AJJQf8VX71eESt XALHC5Vob2VBU+FUPdOopqmfY+974dbA/dCoZ2d6v9BqSAjMEzjVuUjszItHsA4I = Received: (qmail 102842 invoked by alias); 19 Jun 2019 13:10:20 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 102833 invoked by uid 89); 19 Jun 2019 13:10:20 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.redhat.com From: Florian Weimer To: "Dmitry V. Levin" Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v3] libio: do not unbuffer legacy standard files in compatibility mode [BZ #24228] References: <20190218124438.GB20127@altlinux.org> <87mumtcl0w.fsf@oldenburg2.str.redhat.com> <20190218191021.GA25527@altlinux.org> <20190219005741.GA29070@altlinux.org> <20190219012913.GB29070@altlinux.org> Date: Wed, 19 Jun 2019 15:10:14 +0200 In-Reply-To: <20190219012913.GB29070@altlinux.org> (Dmitry V. Levin's message of "Tue, 19 Feb 2019 04:29:13 +0300") Message-ID: <87lfxx4t6x.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain * Dmitry V. Levin: > diff --git a/libio/genops.c b/libio/genops.c > index 2a0d9b81df..aa92d61b6b 100644 > --- a/libio/genops.c > +++ b/libio/genops.c > @@ -789,6 +789,10 @@ _IO_unbuffer_all (void) > > for (fp = (FILE *) _IO_list_all; fp; fp = fp->_chain) > { > +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) > + if (__glibc_unlikely (&_IO_stdin_used == NULL) && _IO_legacy_file (fp)) > + continue; > +#endif > if (! (fp->_flags & _IO_UNBUFFERED) > /* Iff stream is un-orientated, it wasn't used. */ > && fp->_mode != 0) I believe a better fix would be this, in case an old-style file showed up for a different reason: #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) bool potentially_wide_stream = _IO_vtable_offset (fp) != 0; #else bool potentially_wide_stream = true; #endif if (potentially_wide_stream && fp->_mode > 0) _IO_wsetb (fp, NULL, NULL, 0); This is _IO_new_fclose handles this situation. I fear the test is unreliable because it depends on what fp->_mode evaluates to (which is not actually present in the struct with old files). But the test is definitely better than nothing. Thanks, Florian