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!

mballance added a commit that referenced this pull request Oct 6, 2026
Brings in master's wave-3b conversion (tag + release-authority gated PyPI
publish, GitHub Pages deploy deleted, .forgejo/workflows/{ci,docs}.yml) and
the #281/#283 fixes.

Conflict resolution:
- .github/workflows/ci.yml: master's gate job and Pages-deploy removal, kept
  with this branch's boolector/dv-solve matrix, XCHECK soak and ASAN jobs. The
  publish step is gated on the boolector leg, a v* tag and authority ==
  'github'; master's Forgejo shadow check passes against the merged file.
- constraint_dist_scope_model.py: this branch's is_conditional/cond_l fields
  plus master's update_weights(), which now also carries the branch's `:=`
  per-value range-width scaling (previously inline in the builder).
- dist_constraint_builder.py: master's update_weights()/weight-field
  collection with the branch's native flag and priming guard.

dv-solve already honors rand-field dist weights (#283's shape): P(1) tracks
the solved weight on both back-ends (0.24/0.76 vs Boolector 0.25/0.75).

Tests: ve/unit 559 passed on both back-ends, ve/unit_dc 441 passed. Two
pre-existing failures (test_dvsolve_ctypes_wiring, test_dvsolve_lib_load)
fail identically before this merge: the current dv-solve prefixes its C
symbols with dvs_ and builds into build/lib.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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