Crash instead of returning an invalid index value#166
Merged
DanielaOrtner merged 1 commit intoMay 5, 2025
Conversation
53cf854 to
2e40800
Compare
DanielaOrtner
approved these changes
May 5, 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.
Currently, when a new BVH leaf item is requested, if the BVH leaf is full, a value of -1 is returned.
The compiler is raising a array subscript 4294967295 is above array bounds warning when this value is used as an index in an array of fixed size:
The only time a leaf item is requested is when an item is added to a node, and, in debug builds, the returned value is checked and Rebel Engine will crash if it equals
0xffffffff(the overflowed value of -1 for an unsigned 32 bit integer is 4294967295):RebelEngine/core/math/bvh_tree.h
Lines 435 to 436 in 0ded452
RebelEngine/core/math/bvh_tree.h
Line 63 in 0ded452
RebelEngine/core/math/bvh_tree.h
Lines 45 to 50 in 0ded452
It appears that it is currently assumed that no attempt will be made to add an item to a node that is full (and that the node is a leaf node). Addressing the dependence on this assumption will require significant changes to the BVH code. In the meantime, it is easier to simply crash if any attempt is made to request an item from a full leaf node.
This PR cause Rebel Engine to crash whenever a leaf item is requested from a full leaf node; instead of only in debug builds.