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

changes to ptr library #460

Merged
merged 15 commits into from
Nov 13, 2023
Merged

changes to ptr library #460

merged 15 commits into from
Nov 13, 2023

Conversation

tjhance
Copy link
Collaborator

@tjhance tjhance commented Mar 22, 2023

This adds partial support for variable-length allocations in the ptr library.

Changes:

  • In addition to PointsTo<V>, there is also an "untyped PointsTo" called PointsToRaw which maps to an uninitialized region of memory of arbitrary length.
  • PointsTo<V> and PointsToRaw can be converted between each other, provided the size of V is known.
  • There is now a new proof object called Dealloc (and DeallocRaw) which provides the ability to deallocate a region of memory. This has to be separate from PointsTo, because it's possible for a PointsTo object to point into a subregion of an allocation. However, it's not possible to deallocate part of an allocation.
    • The verified_vec example shows a nontrivial use of PointsTo and Dealloc.
  • I replaced the implementation for alloc & dealloc with functions from the allocator_api. It's unstable, but it's easier to use than what we had before.
  • In order to talk about the sizes of types, I added a SizeOf trait. This is incomplete because it doesn't have support from Verus to actually calculate a size or an alignment, and as such, it forces the user to make an assume when they implement the trait.

Right now the tests are failing because of a bug related to lifetime checking & Copy.

@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 5060d0b to 6e0a4e2 Compare April 28, 2023 08:21
@tjhance tjhance changed the base branch from main_new to main April 28, 2023 08:21
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 6e0a4e2 to 723b9a5 Compare April 30, 2023 13:34
@tjhance tjhance marked this pull request as draft April 30, 2023 13:34
@tjhance
Copy link
Collaborator Author

tjhance commented Apr 30, 2023

status: currently requires a fix regarding lifetime checking and Copy

@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 723b9a5 to 47e29d9 Compare May 15, 2023 13:31
@tjhance
Copy link
Collaborator Author

tjhance commented May 15, 2023

status:

  • The lifetime-checking issue with Copy is fixed thanks to chris.
  • However, there's an issue related to provenance that needs to be fixed (the API currently lets you do something UB according to Rust's pointer provenance rules), so I'm going to keep this marked as a draft

@tjhance tjhance force-pushed the new_varlength_ptr_lib branch 2 times, most recently from 26ec838 to 102985e Compare June 9, 2023 01:32
@tjhance tjhance changed the base branch from main to new-vec-support June 9, 2023 02:14
@tjhance tjhance marked this pull request as ready for review June 9, 2023 02:14
@tjhance tjhance force-pushed the new-vec-support branch from cefc301 to 671f4b5 Compare June 9, 2023 16:16
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 102985e to 5d64fb4 Compare June 9, 2023 16:25
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 5d64fb4 to 020cd61 Compare June 12, 2023 14:10
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 020cd61 to 33594b8 Compare June 12, 2023 20:53
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 33594b8 to 43ad2e4 Compare June 13, 2023 14:43
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 43ad2e4 to 194a467 Compare June 13, 2023 18:24
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 194a467 to a924cb0 Compare June 14, 2023 16:07
Base automatically changed from new-vec-support to main June 14, 2023 16:57
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch 2 times, most recently from 7c2d647 to ec543b1 Compare June 19, 2023 13:44
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch 2 times, most recently from eba3a06 to f06f07e Compare June 30, 2023 19:19
@tjhance tjhance marked this pull request as draft July 26, 2023 14:20
@tjhance tjhance force-pushed the new_varlength_ptr_lib branch from 0a46abf to 655731f Compare November 1, 2023 16:44
@utaal utaal force-pushed the new_varlength_ptr_lib branch 5 times, most recently from 6198b72 to 0405f49 Compare November 12, 2023 12:20
@tjhance
Copy link
Collaborator Author

tjhance commented Nov 12, 2023

Was it necessary to use std::alloc? I think this won't work for people using no-std

@utaal
Copy link
Collaborator

utaal commented Nov 12, 2023

cargo build-ing vstd fails with the allocator feature because it's only available on nightly. I don't see a way around that.

But indeed we need to figure out a strategy for no-vstd users.

@utaal utaal force-pushed the new_varlength_ptr_lib branch 2 times, most recently from 146fe0b to 578ec5a Compare November 13, 2023 09:24
@utaal utaal force-pushed the new_varlength_ptr_lib branch from 578ec5a to 7488038 Compare November 13, 2023 09:30
@utaal
Copy link
Collaborator

utaal commented Nov 13, 2023

If the question was specifically about std::alloc vs alloc::alloc, then no. Fixed now.
Also tested with --vstd-no-std and --vstd-no-alloc.

@tjhance tjhance merged commit 6218a43 into main Nov 13, 2023
@tjhance tjhance deleted the new_varlength_ptr_lib branch November 13, 2023 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants