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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GLfB5uWRdmx2WiZSFC7Fm7
This commit is contained in:
Rongsong Shen 2026-09-08 09:16:20 +00:00
parent ffb665023f
commit 4b20590c80
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
2 changed files with 4 additions and 0 deletions

View file

@ -68,6 +68,7 @@ void free_host_account(xce_host_account_t* acct)
FREEUP(acct->accounts);
}
FREEUP(acct->host);
FREEUP(acct);
}

View file

@ -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) ───────