From 7a3d21bb2c1d3d2338cb3e30f99b94545bba368e Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 9 Sep 2026 16:59:06 -0600 Subject: [PATCH] threads: destroy pthread_attr_t before reuse pthread_getattr_np re-initializes the attributes on use causing the original pthread_attr_init to leak. Destroy after use to prevent the memory leak. Ticket: 9032 --- src/tm-threads.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tm-threads.c b/src/tm-threads.c index be2a230eea..4b269600ac 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -1721,6 +1721,7 @@ TmEcode TmThreadSpawn(ThreadVars *tv) } int rc = pthread_create(&tv->t, &attr, tv->tm_func, (void *)tv); + pthread_attr_destroy(&attr); if (rc) { FatalError("Unable to create thread %s with pthread_create(): retval %d: %s", tv->name, rc, strerror(errno)); @@ -1733,6 +1734,7 @@ TmEcode TmThreadSpawn(ThreadVars *tv) void *stack_addr; pthread_attr_getstack(&attr, &stack_addr, &stack_size); SCLogDebug("stack: %p; size %" PRIu64, stack_addr, (uintmax_t)stack_size); + pthread_attr_destroy(&attr); } else { SCLogDebug("Unable to retrieve current stack-size for display; return code from " "pthread_getattr_np() is %" PRId32,