[BugFix] Fix off-by-one error in the type index range check within Object::IsInstance()#17902
Merged
tqchen merged 2 commits intoapache:mainfrom Apr 30, 2025
Merged
Conversation
Contributor
Author
|
@liangfu @tqchen @wweic @cbalint13 @tkonolige @FrozenGene @eqy |
tqchen
requested changes
Apr 29, 2025
…nstance() This PR fixes an off-by-one error in the type index range check within `Object::IsInstance()`. Currently, the condition `self->type_index_ < end` is used to check if a type index falls within a reserved range (`[begin, end)`). However, since end is computed as `begin + _type_child_slots`, this means the range check excludes the last valid index `(end - 1)`. Example: If `begin = 500` and `_type_child_slots = 5`, then `end = 505`. The current check (`500 <= type_index_ < 505`) only allows 500, 501, 502, ..., 504, but logically, 505 should also be included if `_type_child_slots` is meant to cover indices up to `begin + _type_child_slots`.
8e2bd46 to
f72c4f5
Compare
Contributor
Author
|
@tqchen The arm/pr-head CI failed due to Jenkins agent disconnection. Could you please help trigger a rerun action? Thanks! |
Contributor
|
@tvm-bot rerun |
Contributor
Author
Thanks! |
tqchen
approved these changes
Apr 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an off-by-one error in the type index range check within
Object::IsInstance(), an example and steps to reproduce it are at Issue #17901.