Skip to content

fix(builtins): cap parallel cartesian product size to prevent memory blowup#1054

Merged
chaliy merged 3 commits intomainfrom
fix/issue-991-parallel-cartesian-limit
Apr 4, 2026
Merged

fix(builtins): cap parallel cartesian product size to prevent memory blowup#1054
chaliy merged 3 commits intomainfrom
fix/issue-991-parallel-cartesian-limit

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Add MAX_CARTESIAN_PRODUCT constant (100,000) to cap combinations
  • Pre-calculate total product size with checked_mul before allocating
  • Return error with exit code 1 when limit exceeded
  • Small cartesian products still work correctly

Test plan

  • Small products (2x2=4) work correctly
  • Huge products (4^20 ~1 trillion) return error
  • End-to-end test via run_parallel() with 20 groups
  • All existing parallel tests pass

Closes #991

@chaliy chaliy merged commit 4977823 into main Apr 4, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-991-parallel-cartesian-limit branch April 4, 2026 01:15
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.

Parallel builtin cartesian product enables exponential memory blowup

1 participant