From 2e55da911896a91e95b24ab5dc8a9d9b0718f4de Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 29 May 2014 16:35:09 -0400 Subject: remove useless synchronization in exit and quick_exit calling exit more than once invokes undefined behavior. in some cases it's desirable to detect undefined behavior and diagnose it via a predictable crash, but the code here was silently covering up an uncommon case (exit from more than one thread) and turning a much more common case (recursive calls to exit) into a permanent hang. --- src/exit/exit.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/exit/exit.c') diff --git a/src/exit/exit.c b/src/exit/exit.c index 353f50b7..695bdc05 100644 --- a/src/exit/exit.c +++ b/src/exit/exit.c @@ -1,8 +1,6 @@ #include #include #include "libc.h" -#include "atomic.h" -#include "syscall.h" static void dummy() { @@ -21,11 +19,6 @@ extern void (*const __fini_array_end)() __attribute__((weak)); _Noreturn void exit(int code) { - static int lock; - - /* If more than one thread calls exit, hang until _Exit ends it all */ - while (a_swap(&lock, 1)) __syscall(SYS_pause); - __funcs_on_exit(); #ifndef SHARED -- cgit v1.2.1