From 21e6cf10b6d4a0ae5a6c8b8d42cf6dab1557a94f Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 27 Jan 2024 21:53:57 +0000 Subject: [PATCH] Sigh. Linked list bugs. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4806 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- GNUmakefile | 5 +++++ src/task.c | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 8ad2b893..61b24b90 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -213,6 +213,11 @@ debug: LDFLAGS += -fsanitize=address -fsanitize=undefined endif endif +ifeq ($(UNAME_M),aarch64) +debug: CFLAGS += -fsanitize=address -fsanitize=undefined -fno-common +debug: LDFLAGS += -fsanitize=address -fsanitize=undefined +endif + get_objs = \ $(foreach build_type,$(BUILD_TYPES),$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)))))) \ $(foreach build_type,debug release,$(addprefix $(BUILD_DIR)/$(build_type)/,$(addsuffix .o,$(basename $(value $(1)_unix))))) \ diff --git a/src/task.c b/src/task.c index 0e3e1387..cd9b2798 100644 --- a/src/task.c +++ b/src/task.c @@ -2053,15 +2053,14 @@ static void _timeout_link(tf_task_t* task, timeout_t* timeout) { assert(!timeout->previous); assert(!timeout->next); - timeout->previous = task->timeouts ? task->timeouts->previous : timeout; - timeout->next = task->timeouts ? task->timeouts: timeout; + timeout->previous = timeout; + timeout->next = timeout; if (task->timeouts) { + timeout->previous = task->timeouts->previous; + timeout->next = task->timeouts; + task->timeouts->previous->next = timeout; task->timeouts->previous = timeout; - if (task->timeouts->next == task->timeouts) - { - task->timeouts->next = timeout; - } } task->timeouts = timeout; } @@ -2070,7 +2069,7 @@ static void _timeout_unlink(tf_task_t* task, timeout_t* timeout) { assert(timeout->previous); assert(timeout->next); - if (timeout->next == timeout && timeout->previous == timeout) + if (timeout->next == timeout && timeout->previous == timeout && task->timeouts == timeout) { task->timeouts = NULL; } @@ -2105,8 +2104,8 @@ static void _util_timeoutCallback(uv_timer_t* handle) tf_util_report_error(context, result); JS_FreeValue(context, result); JS_FreeValue(context, timeout->_callback); - tf_trace_end(tf_task_get_trace(timeout->_task)); _timeout_unlink(timeout->_task, timeout); + tf_trace_end(tf_task_get_trace(timeout->_task)); uv_close((uv_handle_t*)handle, _timeout_closed); }