Skip to content

Conversation

@ConvolutedDog
Copy link
Contributor

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.

@ConvolutedDog
Copy link
Contributor Author

ConvolutedDog commented Apr 28, 2025

@liangfu @tqchen @wweic @cbalint13 @tkonolige @FrozenGene @eqy
Request for a review.

…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`.
@ConvolutedDog ConvolutedDog force-pushed the ConvolutedDog-off-by-one-bug-fix branch from 8e2bd46 to f72c4f5 Compare April 29, 2025 13:29
@ConvolutedDog
Copy link
Contributor Author

@tqchen The arm/pr-head CI failed due to Jenkins agent disconnection. Could you please help trigger a rerun action? Thanks!

@cbalint13
Copy link
Contributor

@tvm-bot rerun

@ConvolutedDog
Copy link
Contributor Author

@tvm-bot rerun

Thanks!

@ConvolutedDog ConvolutedDog requested a review from tqchen April 30, 2025 01:42
@tqchen tqchen merged commit cbba0e3 into apache:main Apr 30, 2025
10 checks passed
@ConvolutedDog ConvolutedDog deleted the ConvolutedDog-off-by-one-bug-fix branch May 1, 2025 02:29
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.

3 participants