From 4b20590c80d0c75f1e74983e2fdfe212f713d6ac Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Tue, 8 Sep 2026 09:16:20 +0000 Subject: [PATCH] fix(lib): free host_account.host and job_account test fixtures (bug-1723, bug-1621) free_host_account() (src/lib/misc.c) freed acct->accounts[] and acct itself but never acct->host, the strdup'd string make_host_account() (xcealloc.c) allocates -- a real leak on every free_job_account() call, including the live production dispatch path (scheduler.c, core_events.c), not just test fixtures. Already root-caused and the exact fix specified in bug-1621 (logged, never applied); applied here: FREEUP(acct->host) before FREEUP(acct), mirroring free_res_account()'s existing FREEUP(acct->resname) pattern. Also closes bug-1723: test_xcealloc.c's two multi-host overflow regression tests (added by bug-1722's fix) never freed their own locally-built fixture trees. Added free_JobAlloc_ptr(&jalloc) to test_make_job_account_multi_host_no_overflow() and free_HostAlloc_list(2, hallocs) to test_make_host_allocs_multi_host_no_overflow(), exactly as bug-1723's own root-cause note specified. Together these take xcelib_test from a deterministic 456-byte/29- allocation LeakSanitizer SIGABRT (masking every other libxce test result behind it) to 1/1 Ok. Full xce-build.sh all asan --incremental: 94/94 Ok, zero regressions. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01GLfB5uWRdmx2WiZSFC7Fm7 --- src/lib/misc.c | 1 + src/lib/testsuite/test_xcealloc.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/lib/misc.c b/src/lib/misc.c index aba33be4..d5c156a5 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -68,6 +68,7 @@ void free_host_account(xce_host_account_t* acct) FREEUP(acct->accounts); } + FREEUP(acct->host); FREEUP(acct); } diff --git a/src/lib/testsuite/test_xcealloc.c b/src/lib/testsuite/test_xcealloc.c index f472a309..975d3756 100644 --- a/src/lib/testsuite/test_xcealloc.c +++ b/src/lib/testsuite/test_xcealloc.c @@ -58,6 +58,7 @@ static void test_make_job_account_multi_host_no_overflow(void) TEST_ASSERT_EQUAL_STRING("host1", account->accounts[1]->host); free_job_account(account); + free_JobAlloc_ptr(&jalloc); } /* Same bug shape, sibling function: make_host_allocs() allocates its result @@ -91,6 +92,8 @@ static void test_make_host_allocs_multi_host_no_overflow(void) TEST_ASSERT_NOT_NULL(hallocs[1]); TEST_ASSERT_EQUAL_STRING("host0", hallocs[0]->host); TEST_ASSERT_EQUAL_STRING("host1", hallocs[1]->host); + + free_HostAlloc_list(2, hallocs); } /* ── dup_job_alloc() (scheduler-snapshot-job-allocation task 1.1) ───────