This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Fix locking issue in newlocale
- From: Nathan Myers <ncm-nospam at cantrip dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Ulrich Drepper <drepper at redhat dot com>,Glibc hackers <libc-hacker at sources dot redhat dot com>,Paolo Carlini <pcarlini at suse dot de>, Ulrich dot Weigand at de dot ibm dot com,libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 16 Jul 2004 09:43:07 -0700
- Subject: Re: [PATCH] Fix locking issue in newlocale
- References: <40F79EAB.1060107@suse.de> <20040716121639.GJ30497@sunsite.ms.mff.cuni.cz>
On Fri, Jul 16, 2004 at 02:16:39PM +0200, Jakub Jelinek wrote:
> for (i = 0; i < 100000; ++i)
> setlocale (LC_ALL, locales[(i % 27) & 1]);
> ...
> for (i = 0; i < 10; ++i)
> pthread_create (&p[i], NULL, i % 2 ? tf : tf2, NULL);
I'm not sure that we should expect this to be safe anyhow.
Since setlocale is visibly modifying global state, it seems that
the user should be responsible for controlling access to it.
Certainly, if there is any contention, neither thread could count
on getting the result it expected.
Nathan Myers
ncm@cantrip.org