[PATCH] string: New thread-safe strtok version

Cristian Rodríguez cristian@rodriguez.im
Fri Apr 4 10:49:56 GMT 2025


On Wed, Apr 2, 2025 at 10:08 AM enh <enh@google.com> wrote:
>
> On Wed, Apr 2, 2025 at 8:54 AM Cristian Rodríguez <cristian@rodriguez.im> wrote:
> >
> > On Wed, Apr 2, 2025 at 6:31 AM Florian Weimer <fweimer@redhat.com> wrote:
> > >
> > > Introduce a new symbol version, so that applications can rely
> > > on the new behavior.
> > >
> > > The compatibility symbol is not thread-safe and switches to the
> > > BSD-compatible behavior that some historic applications rely on.  See
> > > the previous discussion on bug 16640.
> >
> > I agree with this change in general as there is no good reason to keep
> > it the old way..but is a new symbol really needed ?
> > after all it is unspecified what happens on misuse..
>
> yeah, i was wondering that. bionic silently made similar changes to a
> handful of oft-abused functions (because in an Android app,
> multi-threaded is the default). though i've never knowingly seen a
> problem with strtok(), if you do this, i'll probably do this too...

I have personally not seen strtok abuse or misuse, mostly of the
getpw*_r  interfaces and other _r API that have non obvious usage. the
non r versions could be made safer to use this same way.


More information about the Libc-alpha mailing list