ManagedVec slice + DebugApi issue fix#2402
Merged
Merged
Conversation
…requires_managed_type_drop only called where required, slice fix
|
Contract comparison - from 2f79413 to 4f20e30
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes ManagedVec range-slicing semantics to avoid handle aliasing (notably under DebugApi), and clarifies/adjusts the “drop required” signaling used to choose safe cloning paths for managed (handle-owning) items.
Changes:
- Introduces
ManagedVec::clone_range()as the safe range-clone API and deprecatesslice()as an alias. - Updates
ManagedVecclone/drop logic to distinguish “handle-owning” item types from “backend actually performs drops”. - Adds regression tests (including a
DebugApicase) to ensure slices/clones don’t alias and mutations don’t leak back to the source.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/scenario/tests/managed_vec_test.rs | Adds clone/slice regression tests; migrates tests from slice() to clone_range(); adds a DebugApi regression test. |
| framework/base/src/types/managed/wrapped/managed_vec.rs | Implements clone_range(), deprecates slice(), adjusts clone/drop behavior to avoid aliasing/double-free issues. |
| framework/base/src/types/managed/wrapped/token/payment.rs | Sets ManagedVecItem::requires_drop() to always true for Payment<M>. |
| framework/base/src/types/managed/wrapped/token/fungible_payment.rs | Sets ManagedVecItem::requires_drop() to always true for FungiblePayment<M>. |
| framework/base/src/types/managed/wrapped/token/esdt_token_payment.rs | Sets ManagedVecItem::requires_drop() to always true for EsdtTokenPayment<M>. |
| framework/base/src/types/managed/wrapped/token/egld_or_esdt_token_payment.rs | Sets ManagedVecItem::requires_drop() to always true for EgldOrEsdtTokenPayment<M>. |
| framework/base/src/types/managed/wrapped/managed_vec_item.rs | Adjusts managed-type ManagedVecItem::requires_drop() implementations to always true (handle-owning semantics). |
| framework/base/src/types/managed/wrapped/managed_option.rs | Sets ManagedVecItem::requires_drop() to always true for ManagedOption. |
| framework/base/src/types/managed/wrapped/decimal/managed_decimal.rs | Sets ManagedVecItem::requires_drop() to always true for managed decimals. |
| framework/base/src/types/managed/wrapped/decimal/managed_decimal_signed.rs | Sets ManagedVecItem::requires_drop() to always true for signed managed decimals. |
| framework/base/src/types/managed/multi_value/payment_multi_value.rs | Sets ManagedVecItem::requires_drop() to always true for PaymentMultiValue. |
| framework/base/src/types/managed/multi_value/multi_value_managed_vec_counted.rs | Sets ManagedVecItem::requires_drop() to always true for counted managed-vec multivalue type. |
| framework/base/src/types/managed/multi_value/esdt_token_payment_multi_value.rs | Sets ManagedVecItem::requires_drop() to always true for EsdtTokenPaymentMultiValue. |
| framework/base/src/types/managed/multi_value/egld_or_esdt_token_payment_multi_value.rs | Sets ManagedVecItem::requires_drop() to always true for EgldOrEsdtTokenPaymentMultiValue. |
| framework/base/src/types/interaction/managed_arg_buffer.rs | Sets ManagedVecItem::requires_drop() to always true for ManagedArgBuffer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Pull request overview
This PR fixes
ManagedVecrange-slicing semantics to avoid handle aliasing (notably underDebugApi), and clarifies/adjusts the “drop required” signaling used to choose safe cloning paths for managed (handle-owning) items.Changes:
ManagedVec::clone_range()as the safe range-clone API and deprecatesslice()as an alias.ManagedVecclone/drop logic to distinguish “handle-owning” item types from “backend actually performs drops”.DebugApicase) to ensure slices/clones don’t alias and mutations don’t leak back to the source.