[PATCH] stdlib: Fix data race in __run_exit_handlers

Paul Pluzhnikov ppluzhnikov@google.com
Sat Apr 17 18:01:39 GMT 2021


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

> +   not called more then once.  */

s/then/than/

> +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.


-- 
Paul Pluzhnikov


More information about the Libc-alpha mailing list