-
Notifications
You must be signed in to change notification settings - Fork 129
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
Improve safety of atom tables and RawBlock #2727
base: rebis-dev
Are you sure you want to change the base?
Conversation
Thank you so much for working on this! One question I have regarding these changes: Would it be better to apply them directly to the upcoming Please see the announcement and discussion at: #2569 |
The rebase to |
43046f8
to
e3c6a80
Compare
@bakaq: I would greatly appreciate if you could take a look at these impressive changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Not much to point out that you haven't already acknowledged in TODO comments.
I'm not sure why I would like to suggest in a subsequent PR a way to make the API of |
@adri326: This looks awesome, thank you so much for all these impressive contributions! |
The safety of the operations defined for
Atom
andRawBlock
relied until now on undocumented and unasserted properties of the inputs and the environment.For instance, the following (dubious) library prolog code triggers undefined behavior:
This PR aims to lessen the chance of someone inadvertently causing undefined behavior from an incorrect usage of
Atom
orRawBlock
, by making the following changes:RawBlockTraits::align()
into a constant, to enforce the invariant that it must be constant. This should also slightly improve performance.RawBlock::alloc
not actually aligning thesize
toT::align()
, causing potential UB (all call sites were already aligning the size themselves).AtomData
before the right metadata for its fat pointer is obtained.AtomData
has the expected representation.RawBlock
, to reduce the amount of code that needs to uphold its invariants. The raw accesses are replaced with functions with both checked and unchecked variants.UnsafeCell
withCell
inRawBlock
, as the previous code did not need to hand out mutable borrows toptr
.RawBlock
is still notSync
.ptr
tohead
and store it as an offset frombase
, to reduce the number of pointer operations to keep track of.AtomData
andRawBlock
.AtomData
andRawBlock
.I'm well aware that these are a lot of changes. I split them into multiple commits to make it possible to pull out changes into a future PR if needs be :)