From patchwork Mon Feb 18 21:38:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dmitry V. Levin" X-Patchwork-Id: 1044345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-100130-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="j2ATmEk1"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 443HKm3mMVz9s1l for ; Tue, 19 Feb 2019 08:38:20 +1100 (AEDT) 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=ATU8 327yvR1ttenwhX6kUdL9wbSx7c0vkRLWHNTOqi2zTrzk6hM2VnOA6C9ockhsjejs vPw16xkMLkVO7LwnTNINu67sjfBeY4X4e3GN9qhpd1EvruaCZv1zf2OulzGPHa5Y IIkc3I2yXE3NWlopUQ/Ir7YaWzKA0u8zaLT6mjo= 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=j2ATmEk1vhVJEzxwKWK4qeJnypqHDSbWebTOGoyIVn 9F9nF42L8lYcUzGEYMN2KhRBLn5o+01wRxOW7spLfPANqoiQrDG9rmm3k8NvFDYJ FTbcEHRWURnbt8hxgJ5gw1l7NyitCBU+5lqG+97zySBFPa3GZ034+4mB9VzxtyVq U= 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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 51448 invoked by uid 89); 18 Feb 2019 21:38:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy= 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-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)