Above results in len(job_classes) << len(json_job_classes)
Looking at init/tests/data/upstart-session.json:
grep -B 1 debug upstart-session.json
We see that job_classes are not sorted by session id and instead come in a mixed order.
Thus unconditionally calling "state_index_to_job_class (i)" will return bogus index for the session job_class, and eventually run out of job_classes and start returning NULL for legit system session job_classes.
My fix is to move checking the json_object for session earlier, skip and keep count of json_job_classes with session defined, and changing the call to state_index_to_job_class to correctly account for "gaps", ie. (i - skipped_classes).
Above code is related to the bug in question.
Above results in len(job_classes) << len(json_ job_classes)
Looking at init/tests/ data/upstart- session. json: session. json
grep -B 1 debug upstart-
We see that job_classes are not sorted by session id and instead come in a mixed order.
Thus unconditionally calling "state_ index_to_ job_class (i)" will return bogus index for the session job_class, and eventually run out of job_classes and start returning NULL for legit system session job_classes.
My fix is to move checking the json_object for session earlier, skip and keep count of json_job_classes with session defined, and changing the call to state_index_ to_job_ class to correctly account for "gaps", ie. (i - skipped_classes).
Merge proposal on the way.