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

@ -633,9 +633,14 @@ int instantiate_limit(xce_vres_t** pvres, var resmgr, xce_limit_t* limit,
return rc;
}
/* kill_vres - bug-1884: the usage-instance table's datakiller. Frees only
* the record: its vres/res/percent_res belong to the resource manager and
* its limit to the plugin's limit table. */
void kill_vres(xce_vres_t* vres)
{
if (vres == NULL) {
return;
}
FREEUP(vres);
}