From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: Hans-Peter Nilsson <hp@axis.com>, newlib@sourceware.org
Subject: Re: [PATCH] Fix stdio init handling
Date: Tue, 7 Jun 2022 08:18:49 +0200 [thread overview]
Message-ID: <5ee6a38c-d7f5-ed62-970d-b25aedee3a25@embedded-brains.de> (raw)
In-Reply-To: <20220606182003.DB8A72041A@pchp3.se.axis.com>
[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]
Hello Hans-Peter,
sorry for breaking your Newlib configuration. I was able to reproduce
the issue in RTEMS with a corresponding configuration. The problem
didn't show up in our tests since in RTEMS __getreent() returns a
thread-specific reentrancy structure. With
struct _reent *
__getreent (void)
{
return _impure_ptr;
}
your test case reproduced the issue. Could you please try the attached
patch?
We would like to introduce a configuration option for Newlib to use
thread-local storage for the members of struct _reent:
https://sourceware.org/pipermail/newlib/2022/018855.html
With this option, struct _reent is not defined, so using members of
_GLOBAL_REENT to maintain global Newlib state would not work. This is
why we tried to use dedicated global objects for the FILE object list
and the exit handlers.
We also would like to make the _REENT_GLOBAL_STDIO_STREAMS option the
default Newlib behaviour:
https://sourceware.org/pipermail/newlib/2022/019735.html
--
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ünchen
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
[-- Attachment #2: 0001-Fix-__sglue-inititialization.patch --]
[-- Type: text/x-patch, Size: 991 bytes --]
From 9629ec0b7a2e657d693960269506fcc6c715c6ff Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Tue, 7 Jun 2022 07:55:02 +0200
Subject: [PATCH] Fix __sglue inititialization
Do not initialize __sglue with the FILE objects of _GLOBAL_REENT to avoid a
double use in the !_REENT_SMALL and !_REENT_GLOBAL_STDIO_STREAMS configurations
which didn't use a thread-specific reentrancy structure.
---
newlib/libc/stdio/findfp.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c
index 6933ff1db..ff6804d19 100644
--- a/newlib/libc/stdio/findfp.c
+++ b/newlib/libc/stdio/findfp.c
@@ -41,11 +41,7 @@ const struct __sFILE_fake __sf_fake_stderr =
__FILE __sf[3];
struct _glue __sglue = {NULL, 3, &__sf[0]};
#else
-#ifdef _REENT_SMALL
struct _glue __sglue = {NULL, 0, NULL};
-#else
-struct _glue __sglue = {NULL, 3, &_GLOBAL_REENT->__sf[0]};
-#endif
#endif
#ifdef _STDIO_BSD_SEMANTICS
--
2.35.3
next prev parent reply other threads:[~2022-06-07 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 18:20 Hans-Peter Nilsson
2022-06-06 20:16 ` Jeff Johnston
2022-06-07 6:21 ` Sebastian Huber
2022-06-07 14:47 ` Jeff Johnston
2022-06-07 6:05 ` Torbjorn SVENSSON
2022-06-07 14:40 ` Hans-Peter Nilsson
2022-06-07 6:18 ` Sebastian Huber [this message]
2022-06-07 19:31 ` Sebastian Huber
2022-06-07 23:30 ` Hans-Peter Nilsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ee6a38c-d7f5-ed62-970d-b25aedee3a25@embedded-brains.de \
--to=sebastian.huber@embedded-brains.de \
--cc=hp@axis.com \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).