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/exit.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'stdlib/exit.h') diff --git a/stdlib/exit.h b/stdlib/exit.h index 7f2e679246..dbf9f2d01f 100644 --- a/stdlib/exit.h +++ b/stdlib/exit.h @@ -20,6 +20,7 @@ #include #include +#include enum { @@ -57,11 +58,27 @@ struct exit_function_list size_t idx; struct exit_function fns[32]; }; + extern struct exit_function_list *__exit_funcs attribute_hidden; extern struct exit_function_list *__quick_exit_funcs attribute_hidden; +extern uint64_t __new_exitfn_called attribute_hidden; + +/* True once all registered atexit/at_quick_exit/onexit handlers have been + called */ +extern bool __exit_funcs_done attribute_hidden; + +/* This lock protects __exit_funcs, __quick_exit_funcs, __exit_funcs_done + and __new_exitfn_called globals against simultaneous access from + atexit/on_exit/at_quick_exit in multiple threads, and also from + simultaneous access while another thread is in the middle of calling + exit handlers. See BZ#14333. Note: for lists, the entire list, and + each associated entry in the list, is protected for all access by this + lock. */ +__libc_lock_define (extern, __exit_funcs_lock); + extern struct exit_function *__new_exitfn (struct exit_function_list **listp); -extern uint64_t __new_exitfn_called attribute_hidden; + extern void __run_exit_handlers (int status, struct exit_function_list **listp, -- cgit 1.4.1