[PATCH] stdlib: Fix data race in __run_exit_handlers

Vitaly Buka vitalybuka@google.com
Tue Apr 20 22:51:15 GMT 2021


I guess I forgot to reply to these comments.

On Sat, 17 Apr 2021 at 11:02, Paul Pluzhnikov <ppluzhnikov@google.com>
wrote:

> On Sat, Apr 17, 2021 at 10:23 AM Vitaly Buka via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
>
> > diff --git a/stdlib/test-cxa_atexit-race2.c
> b/stdlib/test-cxa_atexit-race2.c
>
> > +   This test spawns multiple threads, and check the same desctructor is
>
> Typo. Suggest:
>
> This test spawns multiple threads, and checks that the same destructor is
>

Done in the last patch.


>
> > +   not called more then once.  */
>
> s/then/than/
>

Done in the last patch.


>
> > +static void *cb_arg = NULL;
> > +static void
> > +add_handlers (void)
> > +{
> > +  int n = 10;
> > +  for (int i = 0; i < n; ++i)
> > +    __cxa_atexit (&atexit_cb, ++cb_arg, 0);
>
> add_handlers() is called from many threads. This code appears to race on
> cb_arg.
>

We don't have a data race as add_handlers is called from a single
background thread.
Previous patches had more threads but they didn't help to reproduce the
issues.


>
>
> --
> Paul Pluzhnikov
>


More information about the Libc-alpha mailing list