Skip to content

Fix for redundant assertion in ValueRangeAnalysisFactory#2887

Merged
hazendaz merged 2 commits into
spotbugs:masterfrom
gtoison:issue-608-redundant-assertion
Mar 4, 2024
Merged

Fix for redundant assertion in ValueRangeAnalysisFactory#2887
hazendaz merged 2 commits into
spotbugs:masterfrom
gtoison:issue-608-redundant-assertion

Conversation

@gtoison

@gtoison gtoison commented Mar 2, 2024

Copy link
Copy Markdown
Contributor

When a redundant condition is used in an assertion ValueRangeAnalysisFactory tries to compute the position of the end end for the corresponding instruction block. However it uses IFNE.getTarget().getPosition() which returns the position offset (not he position).
Since the offset is zero, this produces and invalid range (end is before start) and BitSet.set(start, end) throws an exception.

Instead compute the end of the block by locating the final athrow

Crash reported in issue #608

@gtoison gtoison marked this pull request as ready for review March 2, 2024 19:32
@hazendaz hazendaz self-assigned this Mar 4, 2024
@hazendaz hazendaz merged commit ac3de21 into spotbugs:master Mar 4, 2024
@hazendaz hazendaz added this to the SpotBugs 4.8.4 milestone Mar 4, 2024
PatrikScully pushed a commit to PatrikScully/spotbugs that referenced this pull request Jun 14, 2024
* test: reproducer for crash in redundant condition assertion

Crash reported in issue spotbugs#608

* fix: calculate the end position of the assert block by finding ATHROW
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.

2 participants