From 9d959d45457a9e1ed4fe403d37767af4f950ee03 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 21 Feb 2023 11:40:33 +0200 Subject: [PATCH 1/2] lib_abort.c: Change call to userspace exit() into syscall _exit() The POSIX standard dictates that during abnormal termination the functions registered by atexit() are _not_ called, also flushing the streams is optional. So in this case, it is perfectly legal / better to call the kernel system call _exit() instead. This fixes regression issues caused by removal exit() from the kernel. --- libs/libc/stdlib/lib_abort.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/libc/stdlib/lib_abort.c b/libs/libc/stdlib/lib_abort.c index 663e22427486c..e15508493e94e 100644 --- a/libs/libc/stdlib/lib_abort.c +++ b/libs/libc/stdlib/lib_abort.c @@ -63,8 +63,8 @@ void abort(void) * a conformant version of abort() at this time. This version does not * signal the calling thread all. * - * exit() will flush and close all open files and terminate the thread. + * _exit() will close all open files and terminate the thread. */ - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } From e6fd7695c19998d239497335b25c1499d34e55dc Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Tue, 21 Feb 2023 16:45:14 +0200 Subject: [PATCH 2/2] libc/lib_assert.c: Remove the re-definition of abort() This should now be irrelevant, as abort() is forwarded to _exit() instead. --- libs/libc/assert/lib_assert.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libs/libc/assert/lib_assert.c b/libs/libc/assert/lib_assert.c index 97bb7517b5e3f..5103c715860f6 100644 --- a/libs/libc/assert/lib_assert.c +++ b/libs/libc/assert/lib_assert.c @@ -27,16 +27,6 @@ #include #include -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* If assert() is called from kernel, must not call user API abort */ - -#ifdef __KERNEL__ -# define abort PANIC -#endif - /**************************************************************************** * Public Functions ****************************************************************************/