Skip to content

Fix crash when coverage exclusions remove an entire range - #281

Merged
mballance merged 1 commit into
fvutils:masterfrom
maikjjeong:codex/fix-coverage-exclusion-ranges
Sep 17, 2026
Merged

mballance merged 1 commit into
fvutils:masterfrom
maikjjeong:codex/fix-coverage-exclusion-ranges

Conversation

@maikjjeong

Copy link
Copy Markdown
Contributor

Covergroups can raise IndexError during construction when an ignore_bins or illegal_bins entry fully removes a normal bin and another exclusion remains. _intersect() rewinds the index after removing a range, but the next exclusion previously reused that index before the outer loop could advance it.

Apply each exclusion across all surviving ranges before moving to the next exclusion. This keeps the index rewind paired with the loop increment and preserves trimming and splitting of partially excluded ranges.

Add regression tests for complete removal, partial trimming, split ranges, exclusion order, and empty inputs. Covergroup tests check both ignore and illegal bins, including retained normal-bin names, excluded-value hit counts, normal-bin hit counts, and coverage.

Fixes #269.

Validation:

  • Before the fix, both new covergroup regressions and two range-removal subcases reproduce IndexError.
  • After the fix, 355 unit tests and 10 range subtests pass with the command below. The run emits deprecation warnings but has no failures.
  • An additional local exhaustive check compared 58,081 range/exclusion combinations against Python set subtraction (endpoints from -2 through 2, up to two intervals in each list); all matched.
PYTHONPATH=src .venv/bin/python -m pytest -q --no-cov --disable-warnings ve/unit \
  --ignore=ve/unit/test_random_dist.py \
  --ignore=ve/unit/vsc_test_case.py \
  --ignore=ve/unit/test_covergroup_programmatic.py \
  --ignore=ve/unit/test_rand_mode.py

Local environment: macOS arm64, Python 3.11.14, PyBoolector 3.2.3.20231106.1, and PyUCIS at 11c39fd03a983fa602eb8967b3640a0fcc532458 from requirements_dev.txt.

@mballance
mballance merged commit 8ecda17 into fvutils:master Sep 17, 2026
2 checks passed
@mballance

Copy link
Copy Markdown
Member

Many thanks for this!

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.

IndexError in RangelistModel.intersect() when using ignore_bins/illegal_bins that fully overlap a bin

2 participants