From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 9D6CF3829BE0 for ; Fri, 10 Jun 2022 11:41:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D6CF3829BE0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy06.your-server.de ([78.46.172.3]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nzd0j-0008gj-5M for newlib@sourceware.org; Fri, 10 Jun 2022 13:41:05 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nzd0j-000E8d-2O for newlib@sourceware.org; Fri, 10 Jun 2022 13:41:05 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id BB33E48019D for ; Fri, 10 Jun 2022 13:41:04 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id MsiqsZzVjD-p for ; Fri, 10 Jun 2022 13:41:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 1E9054801C3 for ; Fri, 10 Jun 2022 13:41:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XXnImDa8npSB for ; Fri, 10 Jun 2022 13:41:01 +0200 (CEST) Received: from [192.168.96.159] (unknown [192.168.96.159]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 078CB48019D for ; Fri, 10 Jun 2022 13:41:01 +0200 (CEST) Message-ID: Date: Fri, 10 Jun 2022 13:41:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v2] Use global stdio streams for all configurations Content-Language: en-US To: newlib@sourceware.org References: <20220608094357.12224-1-sebastian.huber@embedded-brains.de> From: Sebastian Huber In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Authenticated-Sender: smtp-embedded@poldinet.de X-Virus-Scanned: Clear (ClamAV 0.103.6/26568/Fri Jun 10 10:06:23 2022) X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2022 11:41:08 -0000 On 10.06.22 12:45, Corinna Vinschen wrote: > On Jun 8 11:43, Sebastian Huber wrote: >> The _REENT_GLOBAL_STDIO_STREAMS was introduced by commit >> 668a4c8722090fffd10869dbb15b879651c1370d in 2017. Since then it was e= nabled by >> default for RTEMS. Recently, the option was enabled for Cygwin which >> previously used an alternative implementation to use global stdio stre= ams. >> >> In Newlib, the stdio streams are defined to thread-specific pointers >> _reent::_stdin, _reent::_stdout and _reent::_stderr. If the option is= disabled >> (the default for most systems), then these pointers are initialized to >> thread-specific FILE objects which use file descriptors 0, 1, and 2, >> respectively. There are at least three problems with this: >> >> (1) The thread-specific FILE objects are closed by _reclaim_reent(). = This >> leads to problems with language run-time libraries that provide w= rappers to >> the C/POSIX stdio streams (for example C++ and Ada), since they u= se the >> thread-specific FILE objects of the initialization thread. In ca= se the >> initialization thread is deleted, then they use freed memory. >> >> (2) Since thread-specific FILE objects are used with a common output d= evice via >> file descriptors 0, 1 and 2, the locking at FILE object level can= not ensure >> atomicity of the output, e.g. a call to printf(). >> >> (3) There are resource managment issues, see: >> >> https://sourceware.org/pipermail/newlib/2022/019558.html >> >> https://bugs.linaro.org/show_bug.cgi?id=3D5841 >> >> This patch enables the _REENT_GLOBAL_STDIO_STREAMS behaviour for all N= ewlib >> configurations and removes the option. This removes a couple of #ifde= f blocks. >> --- >> v2: >> >> * Add missing ';' to _REENT_INIT_PTR_ZEROED(). >> >> * Rebase to Newlib master. >> >> newlib/README | 6 -- >> newlib/configure.ac | 10 +-- >> newlib/libc/include/sys/config.h | 7 -- >> newlib/libc/include/sys/reent.h | 118 +++---------------------= -- >> newlib/libc/reent/impure.c | 6 -- >> newlib/libc/reent/reent.c | 20 ----- >> newlib/libc/stdio/fcloseall.c | 4 - >> newlib/libc/stdio/findfp.c | 53 +----------- >> newlib/libc/stdio/local.h | 17 ---- >> winsup/cygwin/include/cygwin/config.h | 1 - >> 10 files changed, 14 insertions(+), 228 deletions(-) > LGTM together with your "Fix __fp_lock_all() and __fp_unlock_all()" pat= ch. Thanks for having a look at it. I am on holidays next week. Should I=20 still check it in today? --=20 embedded brains GmbH Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.huber@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht M=C3=BCnchen Registernummer: HRB 157899 Vertretungsberechtigte Gesch=C3=A4ftsf=C3=BChrer: Peter Rasmussen, Thomas= D=C3=B6rfler Unsere Datenschutzerkl=C3=A4rung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/