myxce/.wolf/bugs/bug-1627.md
Rongsong Shen d26ff8870d
feat(buglog): one Markdown record per bug, checked against a record standard
The buglog was one 27K-line JSON file whose fields covered only symptom,
root cause and fix, as free text: 2% of entries named the code version a
bug was found on, 12% the build profile, 36% a way to reproduce, and 58% of
the file was OpenWolf hook auto-detections ("Missing guard clause",
"Function not marked async" on .md files).

- .claude/skills/buglog/bug-record.md: the record standard. Eight
  sections (Summary as the title, Description, Environment, Reproduction;
  Root cause, Fix, Verification, References once fixed), each with the
  content it must contain -- e.g. Environment needs the OS, the libc the
  failing binary loads (from its ELF interpreter: glibc 2.42 in the nix
  shell vs 2.40 on the host), toolchain, build profile and commit.
- .wolf/bugs/<id>.md: 500 records migrated from buglog.json; every field
  verified to round-trip. They carry legacy: true and an explicit "not
  recorded" where the old log had no such field; component derived from
  file paths, severity from keywords (else unknown), fix_commits from
  hashes in status_note/fix that git resolves (91 of 463 fixed).
- .wolf/buglog-archive.json: the 710 hook auto-detections, verbatim.
- .wolf/buglog.json is now an index generated from the records, keeping
  the fields OpenWolf's hooks and `openwolf bug search` read.
- scripts/buglog.py rewritten: new (template + Environment collected from
  the machine and --binary), check, status (refuses a status the record
  doesn't support; fixed needs Root cause, Fix, Verification and
  --commit hashes git resolves), note, recur, set, show, list, triage,
  env, index. 29 unittest cases in scripts/tests/test_buglog.py.
- scripts/git-hooks/pre-commit runs `check --staged`: incomplete staged
  records, a legacy record hand-changed to fixed without the fix-time
  sections, a new record claiming legacy: true, or a stale index refuse
  the commit.
- scripts/gitea-sync.py reads the records: issue body = the record's
  sections plus linked fix commits (origin remote, GITEA_COMMIT_REPO to
  override), and a body hash so an issue's text is refreshed when the
  record changes.
- bug-1866 rewritten to the full standard as the worked example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 03:40:11 +00:00

3.1 KiB

id status status_updated status_note component severity timestamp last_seen occurrences files tags related legacy
bug-1627 fixed 2026-09-24 controller unknown 2026-08-23T05:35:00Z 2026-09-19T09:00:00Z 3
src/controller/job.c
controller
reference-counting
memory-leak
refcount
dispatch_a_job_
pre-existing
bug-1626
true

bug-1627: None yet observed at runtime -- found via code trace during round 3/4 of /kiro-validate-design…

Description

None yet observed at runtime -- found via code trace during round 3/4 of /kiro-validate-design review of scheduler-dispatch-commit.

Environment

Not recorded (migrated from buglog.json).

Reproduction

Not recorded (migrated from buglog.json).

Root cause

dispatch_a_job_() (job.c:831-963) calls reference(j) at line 854 after successfully looking up the job. On FOUR of its failure/return paths it never calls a matching dereference(j): workermgr key_find() failing (rc<0, line 888-890), the worker not being found (w==NULL, line 892-894), the worker not being in a ready state (E_XCE_BAD_WORKER, line 897-909), and xce_startjob_req() itself failing (rc<0, line 956-960 -- found in a later review pass than the first three). (Contrast: the nc<=0 path at line 869-873 and the get_queue_exec() failure path at line 917-925 both correctly dereference(j) before returning.) Each occurrence permanently leaks one reference on the job object. Separately and NOT included in this bug (flagged as a distinct open question, not a confirmed defect): the function also never calls dereference(j) on its normal SUCCESS return path -- this may be an intentional reference hand-off to the job entering its dispatched/running lifetime rather than a bug, and needs its own investigation rather than being folded in here.

Fix

FIXED -- scheduler-dispatch-commit task 3.3. dispatch_a_job_() (job.c) now closes all four leak sites as part of the retryable-failure classify/resolve restructuring the bug's own notes anticipated: XCE_DISPATCH_FAIL_SITE_WORKER_LOOKUP, _WORKER_NULL, _WORKER_NOT_READY, and _RPC_FAILURE each now lock(j, RTTI_LOCK_WRITE), classify via xce_classify_dispatch_fail(), increment job.dispatch_fail_count under that lock, resolve retryable (within XCE_DISPATCH_FAIL_RETRY_BOUND==3) or terminal (mark_job_fail(), mirroring task 3.2's two sibling terminal sites) as appropriate, unlock(j), then dereference(j) -- closing the leak uniformly across all four. Regression-tested via test_dispatch_fail_retry.c's canary-reference technique (task 3.2's own established pattern) at three of the four sites (WORKER_LOOKUP/WORKER_NULL share one test since a black-box test cannot force which of the two an unregistered worker key actually triggers -- both share the identical resolution code shape). RED confirmed first (all 4 new tests failed against the unmodified four sites, git-stash verified), then GREEN after the fix, full controller_unit_test suite run (1056 tests, filtered only for the pre-existing bug-1429 hang) showed zero new failures beyond the pre-existing bug-1561 pair.

Verification

Not recorded (migrated from buglog.json).

References

  • Related: bug-1626