From c6af8a9a3ce137a9704825d173be22a2b2d9cb49 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 5 Aug 2024 11:27:35 -0300 Subject: stdlib: Allow concurrent quick_exit (BZ 31997) As for exit, also allows concurrent quick_exit to avoid race conditions when it is called concurrently. Since it uses the same internal function as exit, the __exit_lock lock is moved to __run_exit_handlers. It also solved a potential concurrent when calling exit and quick_exit concurrently. The test case 'expected' is expanded to a value larger than the minimum required by C/POSIX (32 entries) so at_quick_exit() will require libc to allocate a new block. This makes the test mre likely to trigger concurrent issues (through free() at __run_exit_handlers) if quick_exit() interacts with the at_quick_exit list concurrently. This is also the latest interpretation of the Austin Ticket [1]. Checked on x86_64-linux-gnu. [1] https://austingroupbugs.net/view.php?id=1845 Reviewed-by: Carlos O'Donell --- stdlib/tst-concurrent-quick_exit.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 stdlib/tst-concurrent-quick_exit.c (limited to 'stdlib/tst-concurrent-quick_exit.c') diff --git a/stdlib/tst-concurrent-quick_exit.c b/stdlib/tst-concurrent-quick_exit.c new file mode 100644 index 0000000000..3f321668d6 --- /dev/null +++ b/stdlib/tst-concurrent-quick_exit.c @@ -0,0 +1,22 @@ +/* Check if quick_exit can be called concurrently by multiple threads. + Copyright (C) 2024 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define EXIT(__r) quick_exit (__r) +#define ATEXIT(__f) at_quick_exit (__f) + +#include "tst-concurrent-exit-skeleton.c" -- cgit v1.2.3