fix(scheduler): clock/resval/jobid-format fixes plus REPL live-operator gaps (task 12.5)

Bugs fixed, discovered across a day of live-operator testing against a
real deployed cluster:

- bug-1584: clock anchors never initialized to real wall-clock values,
  timestamps showed system uptime instead of Unix epoch.
- bug-1585: heap-use-after-free in the normal-mode driver's periodic
  resval update path -- core_events.c's RESVALS_FULL/_DELTA handlers do a
  shallow zarray_put() of the wire-decoded xce_val_t*, but driver.c's
  release_translated_payload() unconditionally freed the same decoded
  array right after, so the next periodic report for the same
  worker+resource triggered a UAF read via kill_sched_resval(). New
  regression test: test_resval_ownership.c.
- bug-1587/1588/1591: raw-ns/raw-uint64 jobid/timestamp prints across the
  REPL/SIM family converted to the same human-readable formatting already
  used elsewhere (fmt_jobid(), timestamp formatting).
- bug-1590: repl_info.c's XCE_VAL_NUMERIC checks corrected to
  Value_u_fvalue, fixing `info worker`/`info resource` falling back to
  0.00 for real numeric resvals.

task 12.5 (Req 5.22 amendment) -- five REPL gaps surfaced by a live
operator session, each with its own bug id:
- bug-1594: `continue`/`step` reaching EOF with no breakpoint hit now
  re-enters the REPL via xce_repl_on_replay_complete() instead of exiting
  the process; step/continue issued after replay is already complete
  re-prompt instead of silently exiting.
- bug-1595: `step`/`continue` now echo each input event (not just
  decisions) via repl_print_event_summary(), in real event/decision
  order.
- bug-1593: `info resource <name>|all` now reports resource definition
  metadata restricted to XCE_RESF_GLOBAL/XCE_RESF_SHARED resources, read
  from core->sharedInst, instead of aggregating host-based resources
  across every worker.
- bug-1596: repl_split_tokens() strips one matching pair of surrounding
  quote characters from each token.

See requirements.md's Req 5 AC 22 "Amendment (2026-08-19)" for the full
rationale on each of the five task 12.5 gaps.

Full scheduler suite green (41/42; the one remaining failure,
test_recordstart_symlink_escape_replies_error, is the pre-existing
unrelated bug-1560).
This commit is contained in:
Rongsong Shen 2026-08-19 09:48:46 +00:00
parent 515f4ca098
commit c9acd502c0
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
32 changed files with 2547 additions and 295 deletions

View file

@ -137,11 +137,17 @@ struct xce_sched_core_s {
* Atomically updated by the driver AS A GROUP before each event
* dispatch (design.md's State Management note) -- xce_core_now() reads
* them lock-free, no mutex, safe from both the picker and allocator
* threads. xce_sched_core_init() seeds these to AC 3's Normal-mode row
* (virtual_clock_base=0, real_clock_base=0, speed_num=1, speed_den=1):
* degraded-to-real-wall-clock default, today's existing production
* behavior, preserved until a future simulation driver (Phase 3)
* explicitly reconfigures them.
* threads. xce_sched_core_init() seeds these to a neutral
* (virtual_clock_base=0, real_clock_base=0, speed_num=1, speed_den=1)
* default -- NOT a real wall-clock anchor, despite this field's older
* doc comment claiming otherwise (bug-1584): with both anchors at 0,
* xce_core_now() degrades to raw CLOCK_MONOTONIC-since-boot
* nanoseconds, not epoch time. A real driver must seed a genuine
* wall-clock anchor itself -- the normal-mode driver does so via
* xce_core_set_wallclock_anchor() (scheduler.c's sched_init(), right
* after xce_sched_core_init()); the simulation driver does so via
* sim.c's sim_set_virtual_clock(). Only bare-core test fixtures that
* never call either keep the neutral (0,0,1,1) default.
*/
_Atomic uint64_t virtual_clock_base;
_Atomic uint64_t real_clock_base;
@ -457,6 +463,22 @@ extern int xce_core_end_session(xce_sched_core_t*);
*/
extern uint64_t xce_core_now(xce_sched_core_t*);
/*
* xce_core_set_wallclock_anchor - bug-1584 fix. Seeds virtual_clock_base to
* real epoch time (CLOCK_REALTIME) and real_clock_base to the corresponding
* CLOCK_MONOTONIC reading, so a subsequent xce_core_now() tracks real
* wall-clock time from this instant -- the normal-mode driver's counterpart
* to sim.c's sim_set_virtual_clock() (which anchors virtual_clock_base to a
* `.replay` file's snapshot ts instead). xce_sched_core_init() alone does
* NOT do this -- it leaves both anchors at 0, under which xce_core_now()
* returns raw CLOCK_MONOTONIC-since-boot nanoseconds, not epoch time (see
* this file's own clock-field doc comment above, and core_clock.c's function
* header comment, for the full reasoning). Called once by scheduler.c's
* sched_init(), immediately after xce_sched_core_init() succeeds. No-op if
* core is NULL.
*/
extern void xce_core_set_wallclock_anchor(xce_sched_core_t*);
/*
* xce_core_set_active_for_logging / xce_core_register_tlog_format - Req 5
* AC 3's tlog integration (task 4.5). See core_clock.c's own file header