From 26e70aec7028feeb196744eb97cd2dff3670b7aa Mon Sep 17 00:00:00 2001 From: Paul Pluzhnikov Date: Wed, 20 Sep 2017 09:31:48 -0700 Subject: Fix BZ 14333 --- stdlib/on_exit.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'stdlib/on_exit.c') diff --git a/stdlib/on_exit.c b/stdlib/on_exit.c index 83845e76d8..f4ede2b1a7 100644 --- a/stdlib/on_exit.c +++ b/stdlib/on_exit.c @@ -17,25 +17,30 @@ #include #include "exit.h" -#include #include /* Register a function to be called by exit. */ int __on_exit (void (*func) (int status, void *arg), void *arg) { - struct exit_function *new = __new_exitfn (&__exit_funcs); + struct exit_function *new; + + __libc_lock_lock (__exit_funcs_lock); + new = __new_exitfn (&__exit_funcs); if (new == NULL) - return -1; + { + __libc_lock_unlock (__exit_funcs_lock); + return -1; + } #ifdef PTR_MANGLE PTR_MANGLE (func); #endif new->func.on.fn = func; new->func.on.arg = arg; - atomic_write_barrier (); new->flavor = ef_on; + __libc_lock_unlock (__exit_funcs_lock); return 0; } weak_alias (__on_exit, on_exit) -- cgit v1.2.3-70-g09d2