Comment 1 for bug 1200264

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

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:
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).

Merge proposal on the way.