Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor miri pointer checks #62081

Merged
merged 8 commits into from
Jun 24, 2019
Merged

Commits on Jun 23, 2019

  1. Centralize bounds, alignment and NULL checking for memory accesses in…

    … one function: memory.check_ptr_access
    
    That function also takes care of converting a Scalar to a Pointer, should that be needed.  Not all accesses need that though: if the access has size 0, None is returned.
    Everyone accessing memory based on a Scalar should use this method to get the Pointer they need.
    
    All operations on the Allocation work on Pointer inputs and expect all the checks to have happened (and will ICE if the bounds are violated).
    The operations on Memory work on Scalar inputs and do the checks themselves.
    
    The only other public method to check pointers is memory.ptr_may_be_null, which is needed in a few places.
    With this, we can make all the other methods (tests for a pointer being in-bounds and checking alignment) private helper methods, used to implement the two public methods.
    That maks the public API surface much easier to use and harder to mis-use.
    
    While I am at it, this also removes the assumption that the vtable part of a `dyn Trait`-fat-pointer is a `Pointer` (as opposed to a pointer cast to an integer, stored as raw bits).
    RalfJung committed Jun 23, 2019
    Configuration menu
    Copy the full SHA
    c50b9d1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dcc8371 View commit details
    Browse the repository at this point in the history
  3. clean up internals of pointer checks; make get_size_and_align also ch…

    …eck for fn allocations
    RalfJung committed Jun 23, 2019
    Configuration menu
    Copy the full SHA
    c12c8a7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9c32ede View commit details
    Browse the repository at this point in the history
  5. make code more symmetric

    RalfJung committed Jun 23, 2019
    Configuration menu
    Copy the full SHA
    9492038 View commit details
    Browse the repository at this point in the history
  6. deduplicate some code

    RalfJung committed Jun 23, 2019
    Configuration menu
    Copy the full SHA
    9954af4 View commit details
    Browse the repository at this point in the history
  7. expand comment

    RalfJung committed Jun 23, 2019
    Configuration menu
    Copy the full SHA
    38104ab View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2019

  1. fix reoccurring typo

    RalfJung committed Jun 24, 2019
    Configuration menu
    Copy the full SHA
    7e83028 View commit details
    Browse the repository at this point in the history