From: Corinna Vinschen <vinschen@redhat.com>
To: Bruno Haible <bruno@clisp.org>, bug-gnulib@gnu.org
Subject: Re: [PATCH] Do not decorate symbols as dllexport on Cygwin
Date: Mon, 6 Feb 2023 16:08:32 +0100 [thread overview]
Message-ID: <Y+EX8FEm68UrzaDU@calimero.vinschen.de> (raw)
In-Reply-To: <Y+AeInz+HTNYKQlB@calimero.vinschen.de>
Hi Bruno,
On Feb 5 22:22, Corinna Vinschen wrote:
> On Feb 5 21:41, Bruno Haible wrote:
> > Another option — since we are talking about a single symbol and a single
> > platform — would be if the locking for setlocale_null were not necessary
> > on Cygwin in the first place. I determined that it is necessary by running
> > the unit test gnulib/tests/test-setlocale_null-mt-all.c [3] on Cygwin:
> > without the lock, it crashed within less than 1 second. Could the
> > implementation of setlocale() in Cygwin be changed in such a way that this
> > test does not crash? Then the lock would be necessary.
>
> Well, we could do that by adding Cygwin-internal locking to setlocale
> calls. But that would only be available in the next Cygwin version
> of course.
>
> May I ask what's the idea to provide a thread-safe setlocale? It was
> never defined as thread-safe and POSIX explicitely mentions that. Any
> application expecting to call setlocale thread-safe is broken by design.
> It should use the newlocale/duplocale/uselocale/freelocale API instead,
> isn't it?
Ahhh, I finally see what's going on. The problem is not thread-safety
as such, but thread-safety when reading the value of the LC_ALL category.
Glibc's setlocale isn't entirely thread-safe either, but there's a
difference:
- GLibc creates the global strings returned by setlocale(LC_xxx, NULL)
at the time the locale data is changed. All setlocale(LC_xxx, NULL)
calls only return pointer to strings created earlier.
- Cygwin or, better, newlib, also return a pointer to global strings.
However, while the global strings for the specific categories are
created when the locale is changed, the string returned for LC_ALL
gets created on the fly when setlocale(LC_ALL, NULL) is called.
That's why test-setlocale_null-mt-all fails almost immediately.
I created a patch to newlib's setlocale to tweak the LC_ALL string
each time the locale is changed, while setlocale(LC_ALL, NULL)
just returns the already prepared string.
https://cygwin.com/git/?p=newlib-cygwin.git;a=commitdiff;h=23e49b18ce39
This patch will be in the next Cygwin release 3.4.6.
I'm just a bit fuzzy what patches will be required for gnulib now...
Thanks,
Corinna
next prev parent reply other threads:[~2023-02-06 15:10 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-05 19:43 [PATCH] Do not decorate symbols as dllexport on Cygwin Corinna Vinschen
2023-02-05 20:41 ` Bruno Haible
2023-02-05 20:48 ` Bruno Haible
2023-02-05 21:22 ` Corinna Vinschen
2023-02-06 15:08 ` Corinna Vinschen [this message]
2023-02-06 16:36 ` Bruno Haible
2023-02-06 17:37 ` Bruno Haible
2023-02-06 20:04 ` Corinna Vinschen
2023-02-06 20:38 ` Bruno Haible
2023-02-06 20:43 ` Corinna Vinschen
2023-02-06 20:50 ` Reuben Thomas
2023-02-07 13:22 ` Corinna Vinschen
2023-02-07 15:22 ` Corinna Vinschen
2023-02-10 14:11 ` Reuben Thomas
2023-02-10 14:21 ` Bruno Haible
2023-02-11 11:36 ` Reuben Thomas
2023-02-11 12:06 ` Corinna Vinschen
2023-02-11 12:29 ` Reuben Thomas
2023-02-11 12:40 ` Corinna Vinschen
2023-02-17 9:30 ` Reuben Thomas
2023-02-17 9:58 ` Corinna Vinschen
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
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+EX8FEm68UrzaDU@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=bruno@clisp.org \
--cc=bug-gnulib@gnu.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).