From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id ACE573858D33 for ; Fri, 10 Nov 2023 15:17:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACE573858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ACE573858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699629479; cv=none; b=UVtmHQqjtizpt9lkhgiZ0YEckL8fjKTgZlOzRrzUPUc1HBAPvYQcdpnadzqonrlQy8bNzPhzbiYwbrH5Ph9U3Zkwv3uFuxFbsxRL/auDuU35vNIcG/d3WcYolsa9OYf4VWJ7bfsKPr0FTLT0yupzZSwZYPFOHhIG4L/t5POacEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699629479; c=relaxed/simple; bh=oBBOPo7+6Yy5VVC694Xf2gp7mKGjPSaW17EkcyQ0pqI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=O0+VSAUedR8A7h018OAwvZUWgbu15le7H0tQBJW954MoJZIW8lDnSaBL0B/iKkgQNxGTy39KhbfQbKIfrRngZ5aYYA3nxlMMJ0Nn3HB0m1HPV7/aIyXrgYwlxfJrKIg1eZ9Je0/e9ine3gtnY0eHFcmJ/yoiHPGwciQCsezarSo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699629469; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Mm6Ye8JRi3Z/gd0xmUA4+LLeeX1mFCVWcqB2UDM0O90=; b=C5X9jMZZzEJeFJHKOGsJRbuJUkJJB44AWKjKKyUnRs3vEJ3fREV8i/jCdb2rYwjaSEaYeB gcxm9gPpFM0QgVygjbRspeUYQaYnW2QL7D2XojffSVjg9VUgvWw57FwJgqn2a+niDkpUSt M/IhXD3nq5/DUx4FSnYn9RjSu4sqCzs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-C_pJ7-_ePGKAApwZe48qxg-1; Fri, 10 Nov 2023 10:17:47 -0500 X-MC-Unique: C_pJ7-_ePGKAApwZe48qxg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 71785811E8F for ; Fri, 10 Nov 2023 15:17:47 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.192.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E0D040C6EB9 for ; Fri, 10 Nov 2023 15:17:47 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id E6A73A80BA6; Fri, 10 Nov 2023 16:17:45 +0100 (CET) Date: Fri, 10 Nov 2023 16:17:45 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH] newlib: libc: Fix bugs in the commit 3d94e07c49b5. Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20231110113436.2022-1-takashi.yano@nifty.ne.jp> MIME-Version: 1.0 In-Reply-To: <20231110113436.2022-1-takashi.yano@nifty.ne.jp> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Nov 10 20:34, Takashi Yano wrote: > The commit 3d94e07c49b5 has a few bugs which cause testsuite failure > in libstdc++. This is due to excess orientation check in __srefill_r() > and _ungetc_r(). This patch fixes them. Oops, _ungetc_r is used from ungetwc as well, that's not good. Sorry that I missed that yesterday! > Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.") > Reported-by: Christophe Lyon > Reviewed-by: > Signed-off-by: Takashi Yano > --- > newlib/libc/stdio/refill.c | 3 --- > newlib/libc/stdio/ungetc.c | 8 ++------ > 2 files changed, 2 insertions(+), 9 deletions(-) > > diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c > index c1ef7e120..cd71ed152 100644 > --- a/newlib/libc/stdio/refill.c > +++ b/newlib/libc/stdio/refill.c > @@ -43,9 +43,6 @@ __srefill_r (struct _reent * ptr, > > CHECK_INIT (ptr, fp); > > - if (ORIENT (fp, -1) != -1) > - return EOF; > - > fp->_r = 0; /* largely a convenience for callers */ > > /* SysV does not make this test; take it out for compatibility */ > diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c > index 79914af08..5053fd6c4 100644 > --- a/newlib/libc/stdio/ungetc.c > +++ b/newlib/libc/stdio/ungetc.c > @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr, > > _newlib_flockfile_start (fp); > > - if (ORIENT (fp, -1) != -1) > - { > - _newlib_flockfile_exit (fp); > - return EOF; > - } > - > /* After ungetc, we won't be at eof anymore */ > fp->_flags &= ~__SEOF; > > @@ -213,6 +207,8 @@ int > ungetc (int c, > register FILE *fp) > { > + if (ORIENT (fp, -1) != -1) > + return EOF; > return _ungetc_r (_REENT, c, fp); > } > #endif /* !_REENT_ONLY */ > -- > 2.39.0 Didn't you forget ungetwc? But then again, I checked GLibC, and there's something weird: ungetc does not at all set or test the orientation. ungetwc sets the orientation to 1, but doesn't check it. Puzzeling. I wonder about the reasoning behind this. Corinna