fix(scheduler): tear down the simulator and the core's registries at exit (bug-1884, part 1)

A batch --sim replay under ASAN exited 1 on 17.2 MB of LeakSanitizer
reports. This removes all but 75 KB:

- sched_sim_driver_fini() (called by main after a clean run) cancels and
  joins the picker/allocator threads like sched_fini(), closes the replay,
  alternate-events and output files, and finalizes the core. The threads'
  ids now live in core.jobpicker/allocator, as in normal mode.
- xce_sched_core_fini() destroys the plugin, job, worker, queue, user and
  project registries and the shared-resource arrays it creates.
- The seqjob/parjob sched_make_allocs() stand-ins set up only lock, nextid
  and the aliased resmgr. Each ran a full xce_sched_core_init(), which also
  replaced the process-wide string and selector tables mid-startup.
- plugin_unregister(), the plugin registry's datakiller, only runs fini_fn;
  it key_del()'d from the registry being destroyed and skipped plugins
  registered with plugin_register_core().
- The limit plugin's usage-instance table used kill_limit as datakiller on
  xce_vres_t records (bad free on destroy); kill_vres now frees the record.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-29 08:50:59 +00:00
parent 5f8d6b5146
commit 9b61fd99e4
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
9 changed files with 169 additions and 54 deletions

View file

@ -261,6 +261,16 @@ extern int sched_sim_driver_start(xce_sched_sim_driver_t* sim,
extern int sched_sim_driver_run(xce_sched_sim_driver_t* sim,
const sched_sim_args_t* args);
/*
* sched_sim_driver_fini - bug-1884: releases what a sched_sim_driver_run()
* that returned 0 left behind: cancels and joins the picker and allocator
* threads (the way sched_fini() does in normal mode), closes the replay,
* alternate-events and output files, and finalizes the core. Call it only
* after sched_sim_driver_run() returned 0; a failed run has either
* finalized the core already (a startup failure) or is about to exit.
*/
extern void sched_sim_driver_fini(xce_sched_sim_driver_t* sim);
/*
* sim_prescan_next_nonempty_session - user-requested (2026-09-11): looks
* ahead in sim->replay_file (from its CURRENT read position) for the next