Skip to content
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
merged 4 commits into from
Apr 24, 2020

Conversation

arhag
Copy link
Contributor

@arhag arhag commented Apr 23, 2020

Change Description

This PR change the implementation of is_aliasing in preconditions.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 of core_precondition and the change in the definition of to_span) to allow alias checking involving vm::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 intrinsics kv_set and kv_get.

In addition, the changes to to_span are now also careful to avoid constructing a span<T> using a possibly unaligned void*. To be safe, we need to ensure that the void* passed by the WASM code is properly aligned before using it to construct a span<T>. This requires changes in EOS VM. We currently don't have an issue because we only use span<char> and span<const char>. More work is involved if we want to support span<T> for general T with stricter alignment requirements. Therefore, the currently unnecessary alignment check for spans in core_precondition has been removed and the comment under is_whitelisted_type has been updated.

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

arhag added 3 commits April 23, 2020 13:46
Also no need for alignment check in core_precondition because we only use spans of [const] char for now and EOS VM does not properly support spans of general types due to alignment problems.
Fixes corner cases of aliasing check that the previous implementation failed at.

The kv_tests/alias unit tests now pass.
@arhag arhag merged commit b4b04b5 into kv-database Apr 24, 2020
@arhag arhag deleted the kv-database-fix-aliasing branch April 24, 2020 18:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants