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 622901F453 for ; Mon, 18 Feb 2019 21:38:17 +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:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=awuY 5h7TWjuF3S4xmqrFg4bf8LCITUdKFne8MJ2EFskuzHnd/1sWJBZqu470g4ezerut 4se8B0dZlv+Vxz0JW9FyYE5HMVCrLlVVYXMH2sfWQMtnixd1XZ8/6PshrXvhgldo Ow3el1in9YWQY0sogUwWSczneViaEvDU8qejuJM= 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:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=wQ0LPqhnzt FdNfXIjQHFjK6MRoc=; b=PunEjcjTkosGJwVxu7lIKZz1tJGAhnmxotSys79bDf NMb9BG4r3hjmJGbrMwKnmbDDoQcX3Qz9EGin5VeLWJA/rj5mYhRTO6/CACCUEgtH SjLXP/oL3Al0jf55s5TPvauWQBtQg8U7QTtRhyE5s+o1gIYn3f+6MLnYUZ95FhI8 8= Received: (qmail 51491 invoked by alias); 18 Feb 2019 21:38:14 -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 51448 invoked by uid 89); 18 Feb 2019 21:38:13 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: vmicros1.altlinux.org Date: Tue, 19 Feb 2019 00:38:09 +0300 From: "Dmitry V. Levin" To: libc-alpha@sourceware.org Subject: [PATCH v2] libio: do not cleanup wide buffers of legacy standard files [BZ #24228] Message-ID: <20190218213809.GA27785@altlinux.org> References: <20190218124438.GB20127@altlinux.org> <87mumtcl0w.fsf@oldenburg2.str.redhat.com> <20190218191021.GA25527@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190218191021.GA25527@altlinux.org> Commit glibc-2.23~693 (a601b74d31ca086de38441d316a3dee24c866305) introduced a regression: _IO_unbuffer_all() now invokes _IO_wsetb() to free wide buffers of all files, including legacy standard files that are small statically allocated objects that do not have wide buffers and the _mode member. Fix this by skipping _IO_wsetb() invocation for legacy standard files. [BZ #24228] * libio/genops.c (_IO_unbuffer_all) [SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)]: Skip _IO_wsetb() invocation for legacy standard files in compatibility mode. --- ChangeLog | 7 +++++++ libio/genops.c | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libio/genops.c b/libio/genops.c index 2a0d9b81df..95d53595a2 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -816,8 +816,11 @@ _IO_unbuffer_all (void) _IO_SETBUF (fp, NULL, 0); - if (fp->_mode > 0) - _IO_wsetb (fp, NULL, NULL, 0); +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) + if (__glibc_likely (&_IO_stdin_used != NULL) || !_IO_legacy_file (fp)) +#endif + if (fp->_mode > 0) + _IO_wsetb (fp, NULL, NULL, 0); #ifdef _IO_MTSAFE_IO if (cnt < MAXTRIES && fp->_lock != NULL) -- ldv