Skip to content

Fix out-of-bounds panic in progress printer

Warren Gifford requested to merge mrn/fix-out-of-bounds into main

Created by: mrnugget

We ran into an out-of-bounds panic when we had more tasks reporting as "currently running" than the number of status bars we had.

That was due to a lack of defensive checks in the face of a possible race condition.

The race condition leads the PrintStatuses method seeing more "currently running" tasks than there can technically be.

The race condition is between the PrintStatus method that prints the slices of pointers to *TaskStatus and the tasks themselves updating the status non-atomatically.

At least that's what it seems like. I'm not 100% sure about the cause yet, but I could reproduce the issue by simply injecting more statuses at the top of PrintStatuses. The code here fixes it.


I'm still trying to find out exactly why it happens, but I do think this code should be in there in any case, that's why I'm opening up this PR.

Merge request reports

Loading