This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Fix aliasing issues with new host function system #8996
Merged
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.
Change Description
This PR change the implementation of
is_aliasing
inpreconditions.hpp
to fix bugs exhibited during certain corner cases of aliasing. The previous implementation would consider those cases (having to do with empty spans) to be aliasing whereas the new one is more permissive. The new behavior allows us to define the aliasing behavior simply: aliasing occurs if the intersection of two ranges is not empty.The PR also makes additional bug fixes in
preconditions.hpp
(see definition ofcore_precondition
and the change in the definition ofto_span
) to allow alias checking involvingvm::argument_proxy<T*>
to work properly; before it would never consider such pointers to be aliasing even in cases where it should have been.The
kv_tests/alias
unit tests were added to check for various cases of aliasing or non-aliasing with the two KV database intrinsicskv_set
andkv_get
.In addition, the changes to
to_span
are now also careful to avoid constructing aspan<T>
using a possibly unalignedvoid*
. To be safe, we need to ensure that thevoid*
passed by the WASM code is properly aligned before using it to construct aspan<T>
. This requires changes in EOS VM. We currently don't have an issue because we only usespan<char>
andspan<const char>
. More work is involved if we want to supportspan<T>
for generalT
with stricter alignment requirements. Therefore, the currently unnecessary alignment check for spans incore_precondition
has been removed and the comment underis_whitelisted_type
has been updated.Consensus Changes
API Changes
Documentation Additions