Skip to content

CA-423576: fix cli_progress_bar crashes#6892

Merged
edwintorok merged 4 commits intoxapi-project:masterfrom
edwintorok:private/edvint/progress-fix
Feb 5, 2026
Merged

CA-423576: fix cli_progress_bar crashes#6892
edwintorok merged 4 commits intoxapi-project:masterfrom
edwintorok:private/edvint/progress-fix

Conversation

@edwintorok
Copy link
Member

cli_progress_bar is used by xe --progress, and I've reused it in my test code in #6858.
However >90% of my test runs failed on various machines due to a String.blit exception from cli_progress_bar.

There are 2 possible reasons, not sure which one caused the failure, but I've fixed both, and now I have a lot more green tests (and the failures are due to actual bugs in the product, not bugs in the progress bar):

  • if the ETA printed would be >99h (even just temporarily) then we'd overflow the buffer's size and raise an exception. %02d means at least 2 digits, not at most!
  • if time goes backwards then we'd get a negative ETA and try to print a - and overflow the buffer size again and raise an exception. Replaced it with monotonic time

This also contains an improvement I've made on the other PR to print total time in ms (to avoid having to solve rebase conflicts twice in the 2 PRs). This avoids printing awkward looking lines like Total time 00:00:00, when it actually took 0.9s maybe.

This will be reused by some test code.

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
Got some `String.blit` exceptions, which could've happened if the calculated
time was negative, and thus exceeded 10 digits when printed with `eta`.

Use monotonic time instead, so that we don't crash when the clock is adjusted.

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
The ETA is copied into a preallocated bytes buffer of fixed length.
When the ETA exceeds 99h then drop the seconds and report just `hh:mm`.
If it still doesn't fit then replace it with a static string '++:++:++'
(this would only happen if the ETA is >11 years, although it could happen if an
operation became stuck. The operation could still recover and then the ETA will
print a number).

This could also happen if a task makes near 0 progress by the time we attempt to
print progress, which would result in a near infinite ETA.

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
Currently total time is printed as `hh:mm:ss`, and that will be 00:00:00 if
an operation takes <1s.
But that is confusing when an operation takes 0.9s for
example.

Using Mtime.Span.pp instead, which prints values at an appropriate scale based
on their magnitude.

Signed-off-by: Edwin Török <edwin.torok@citrix.com>
@edwintorok edwintorok force-pushed the private/edvint/progress-fix branch from 793d5f4 to b9cd1e5 Compare February 5, 2026 09:31
@edwintorok edwintorok enabled auto-merge February 5, 2026 14:02
Copy link
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised by the amount of custom code to print the time, there's possibility for further enhancements here

@edwintorok edwintorok added this pull request to the merge queue Feb 5, 2026
Merged via the queue into xapi-project:master with commit 90d6814 Feb 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants