Skip to content

precompilation: fix show_progress crash when bar.current goes negative#61335

Merged
IanButterworth merged 4 commits intoJuliaLang:masterfrom
IanButterworth:ib/precomp_bar_fix
Mar 16, 2026
Merged

precompilation: fix show_progress crash when bar.current goes negative#61335
IanButterworth merged 4 commits intoJuliaLang:masterfrom
IanButterworth:ib/precomp_bar_fix

Conversation

@IanButterworth
Copy link
Copy Markdown
Member

Fixes #61333

There's likely a better fix for locking around incrementing these counters together, but I'd handle that after #60943

So just protect for now.

There is a race between the print loop task and worker tasks: when a
package is already up-to-date, a worker increments n_already_precomp[]
before incrementing n_done[], so the print loop can observe a window
where n_done[] - n_already_precomp[] is transiently negative. This
caused show_progress to compute a negative n_filled and crash with
"can't repeat a string -1 times". Guard both bar.current and bar.max
with max(0, ...) to avoid this.

Fixes JuliaLang#61333

Co-Authored-By: Claude <claude@users.noreply.github.com>
@IanButterworth IanButterworth added backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13 labels Mar 16, 2026
@KristofferC
Copy link
Copy Markdown
Member

KristofferC commented Mar 16, 2026

It might be worth making the actual printing code more robust as well, like clamping these values:

n_filled = floor(Int, max_progress_width * perc / 100)
partial_filled = (max_progress_width * perc / 100) - n_filled
n_left = max_progress_width - n_filled

Co-Authored-By: Claude <claude@users.noreply.github.com>
@IanButterworth IanButterworth added the merge me PR is reviewed. Merge when all tests are passing label Mar 16, 2026
Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com>
Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com>
@IanButterworth IanButterworth merged commit a264a3d into JuliaLang:master Mar 16, 2026
8 checks passed
@IanButterworth IanButterworth deleted the ib/precomp_bar_fix branch March 16, 2026 23:09
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Mar 19, 2026
KristofferC pushed a commit that referenced this pull request Mar 24, 2026
@KristofferC KristofferC mentioned this pull request Mar 24, 2026
27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 1.12 Change should be backported to release-1.12 backport 1.13 Change should be backported to release-1.13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

precompilation: show_progress throws: can't repeat a string -1 times

4 participants