From 9eaa6527f73b9e219c93b895a9f32684f7f875f4 Mon Sep 17 00:00:00 2001 From: Itamar Date: Mon, 29 Mar 2021 15:36:42 +0300 Subject: [PATCH] LibC: Mark atexit() entries as 'called' before calling them This guards as from recursing into an atexit callback if exit() is called from within it. --- Userland/Libraries/LibC/cxxabi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/cxxabi.cpp b/Userland/Libraries/LibC/cxxabi.cpp index 064c39d87d..f6819d40ea 100644 --- a/Userland/Libraries/LibC/cxxabi.cpp +++ b/Userland/Libraries/LibC/cxxabi.cpp @@ -101,10 +101,10 @@ void __cxa_finalize(void* dso_handle) bool needs_calling = !exit_entry.has_been_called && (!dso_handle || dso_handle == exit_entry.dso_handle); if (needs_calling) { dbgln_if(GLOBAL_DTORS_DEBUG, "__cxa_finalize: calling entry[{}] {:p}({:p}) dso: {:p}", entry_index, exit_entry.method, exit_entry.parameter, exit_entry.dso_handle); - exit_entry.method(exit_entry.parameter); unlock_atexit_handlers(); exit_entry.has_been_called = true; lock_atexit_handlers(); + exit_entry.method(exit_entry.parameter); } } }