Fix metadata on PtrToPtr cast#941
Merged
automergerpr-permission-manager[bot] merged 4 commits intomasterfrom Feb 18, 2026
Merged
Fix metadata on PtrToPtr cast#941automergerpr-permission-manager[bot] merged 4 commits intomasterfrom
PtrToPtr cast#941automergerpr-permission-manager[bot] merged 4 commits intomasterfrom
Conversation
dkcumming
commented
Feb 17, 2026
Merged
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.
PtrToPtrcasts were mistakenly ignoring metadataORIGIN_SIZEand setting it tonoMetadataSizeafter the cast each time. This PR preserves theORIGIN_SIZEacross the cast.More Details
This issue was discovered working with
Iterators, in particular the relationship betweenstd::slice::Iter<'_, T>::newand<std::slice::iter<'_, thing> as std::iter::Iterator>::next. When iterating through a collection there was no match at the end that should of terminated iterating. An Iter tracks position through the collection with 2 pointers:In order to terminate

ptr == end_or_len, however in KMIR this check was always failing due to the pointer representation:Pointers in KMIR check equality on all metadata fields, so this equality would never pass. The correct
ORIGIN_SIZEshould bedynamicSize(2)as they are pointers to elements of a slice. TheIteris instantiated with the incorrectORIGIN_SIZE.The construction of an

Iterby thenewfunction does a series of pointer casts. The cast that strips theORIGIN_SIZEin KMIR came from_5 = Cast-PtrToPtr mv(6)which is a cast of*mut Thingto*const Thing: