Skip to content

Reject overflowing replication widths before constant folding - #5

Closed
willpartcl wants to merge 1 commit into
boson-basefrom
will/fix-replication-width
Closed

willpartcl wants to merge 1 commit into
boson-basefrom
will/fix-replication-width

Conversation

@willpartcl

@willpartcl willpartcl commented Oct 21, 2026 •

Copy link
Copy Markdown

Oversized nested replications such as {16777216{{256{1'b0}}}} wrap the computed width to zero before requireValidBitWidth runs. Constant folding then reaches a malformed value and can SIGSEGV. A nonzero wrap, such as count 16777217, fails similarly.

Perform the multiplication in a 64-bit SVInt so the existing width guard sees the complete result and emits ValueExceedsMaxBitWidth before folding. The signed 32-bit count and supported operand width fit safely in this width; valid limits and diagnostics stay unchanged.

Regression tests cover seven oversized count/width pairs with 0, 1, and x bits, plus valid small and maximum-width vectors. Before the fix the overflow regression SIGSEGVs while the maximum-width control passes. After the fix all 2,208 unit tests pass (22,128 assertions). The repository pre-commit checks pass on both changed files. Tests ran on SLURM; detailed logs are in /media/nvme1/tmp/will-issuefix/work/replication-width/.

Addresses partcleda/boson#5421; Boson will receive the fix via its yosys-slang submodule pin.

AI disclosure: implemented and tested with OpenAI Codex. Draft pending the human review required by CONTRIBUTING.md; no reviewer requested.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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