feat(job-array-single-wal-record): harden jobj.c job construction primitives

- job_init() now checks makeJobsub()/makeString(ckptinfo) return
  values and propagates failure instead of storing NULL with a
  success return (Req 10.1).
- Root-caused the previously observed makeJobsub() NULL-with-EINVAL
  failure to a test-binary-only hazard: multiple controller test
  files each called job_obj_init() from their own setUp() with no
  cross-file coordination, re-running jobsub_table_init() against an
  already-live lock/table. Fixed via atomic_flag-guarded idempotent
  job_obj_init()/job_obj_fini(), plus a distinct -ENODEV return from
  makeJobsub()/makeJobstartinfo() when the table isn't ready
  (previously fell through to undefined behavior) (Req 10.2).
- Verified (test) MOVE_PTR fields are always NULL on a freshly-built
  submission payload -- no code change needed (Req 10.3).
- Fixed job_destroy()'s accounts leak via the existing
  free_job_account() helper, replacing the stale FIXME (Req 10.4).
- Verified (inspection + test) struct Job's capnp schema has no
  ckptinfo field, so decode_Job/free_Job have nothing to leak there
  -- no code change needed (Req 10.5).

Independently re-verified: reviewer reproduced a pre-existing,
unrelated rtti-library leak-on-init-failure against a stashed
pre-task copy of jobj.c to confirm it predates this change.

Task 1.3 of job-array-single-wal-record.
This commit is contained in:
Rongsong Shen 2026-07-14 08:29:45 +00:00
parent bc4e70b790
commit 76862bd9aa
5 changed files with 541 additions and 8 deletions

View file

@ -26,6 +26,7 @@ extern void test_select(void);
extern void test_bitset(void);
extern void test_kv(void);
extern void test_jobobj(void);
extern void test_jobj_hardening(void);
extern void test_qobj(void);
extern void test_wobj(void);
extern void test_request(void);
@ -140,6 +141,7 @@ int main(int argc, char* argv[])
TEST(test_bitset);
TEST(test_kv);
TEST(test_jobobj);
TEST(test_jobj_hardening);
TEST(test_wobj);
TEST(test_qobj);
TEST(test_request);