Description
Defining ignore_bins/illegal_bins that fully overlap one or more coverpoint bins causes an IndexError during covergroup construction. The crash occurs in RangelistModel.intersect() in rangelist_model.py.
Minimal Reproducible Example
@vsc.randobj
class Item:
def __init__(self):
self.x = vsc.rand_uint8_t()
@vsc.covergroup
class Cg:
def __init__(self):
self.with_sample(dict(it=Item()))
self.options.name = "cg"
self.cp = vsc.coverpoint(
self.it.x,
bins={
"min": vsc.bin(0),
"mid": vsc.bin([1, 254]),
"max": vsc.bin(255)
},
ignore_bins={
"ignore_0": vsc.bin(0),
"ignore_1": vsc.bin(1)
}
)
cg = Cg()
Expected behavior
Covergroup constructs successfully. Bins fully covered by ignore_bins are removed, partially overlapping bins are trimmed.
Actual output
...coverage.py:216, in covergroup.<locals>.build_model(self)
...
---> 81 self.range_l[rng_i],
82 r)
83 rng_i += 1
IndexError: list index out of range
The above exception is thrown.
Root Cause
In RangelistModel.intersect(), when _intersect() pops a range (because it is fully included in an ignore bin), rng_i is decremented to -1. The outer for loop over other.range_l then continues iterating and accesses self.range_l[rng_i] - which is self.range_l[-1], i.e. the last element - causing incorrect behavior or an IndexError on the next iteration of the while loop when the list is empty.
Additional Notes
The same issue occurs with illegal_bins, as they use the same intersect() code path during covergroup construction.
Description
Defining
ignore_bins/illegal_binsthat fully overlap one or more coverpoint bins causes anIndexErrorduring covergroup construction. The crash occurs inRangelistModel.intersect()inrangelist_model.py.Minimal Reproducible Example
Expected behavior
Covergroup constructs successfully. Bins fully covered by
ignore_binsare removed, partially overlapping bins are trimmed.Actual output
The above exception is thrown.
Root Cause
In
RangelistModel.intersect(), when_intersect()pops a range (because it is fully included in an ignore bin),rng_iis decremented to-1. The outerforloop overother.range_lthen continues iterating and accessesself.range_l[rng_i]- which isself.range_l[-1], i.e. the last element - causing incorrect behavior or anIndexErroron the next iteration of thewhileloop when the list is empty.Additional Notes
The same issue occurs with
illegal_bins, as they use the sameintersect()code path during covergroup construction.