Skip to content

fix(par2): fall back to article-size block when SliceSize exceeds file size#223

Merged
javi11 merged 1 commit into
mainfrom
claude/nervous-pike-375556
Apr 29, 2026
Merged

fix(par2): fall back to article-size block when SliceSize exceeds file size#223
javi11 merged 1 commit into
mainfrom
claude/nervous-pike-375556

Conversation

@javi11
Copy link
Copy Markdown
Owner

@javi11 javi11 commented Apr 28, 2026

Summary

  • Fixes segfault in internal/par2 on Linux CI (run #25039127340)
  • When configured SliceSize > file.Size, the previous code clamped to (file.Size/128)*128 ≈ file.Size, creating only 1–2 input slices with a near-zero last slice — a pathological configuration that triggers undefined behavior in the ParPar C SIMD backend (AVX-512) on Linux x86_64
  • Fix: skip the configured SliceSize when it exceeds the file and fall back to calculateParBlockSize(), which produces a sensible number of equal slices (same as par2go's own tests use)

Test plan

  • All ./internal/par2/... unit tests pass locally (ok in 0.6s)
  • TestIntegration_NativeExecutor_RegeneratesWhenNoPar2FilesExist (the previously crashing test) should now pass on Linux CI
  • No behavior change for large files where SliceSize <= file.Size

…e size

When the configured SliceSize is larger than the file being processed,
the previous code clamped it to (file.Size/128)*128, which produces a
block size ≈ file.Size. This creates only 1-2 input slices with a
nearly-zero last slice — a pathological configuration that triggers
undefined behavior in the ParPar C SIMD backend (AVX-512) on Linux
x86_64, causing a segfault in CI.

Instead, fall back to calculateParBlockSize() which yields a sensible
number of equal slices (same as par2go's own test suite uses), and is
known-safe on all platforms.
@javi11 javi11 merged commit 44d0759 into main Apr 29, 2026
3 of 4 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.

1 participant