-
Notifications
You must be signed in to change notification settings - Fork 295
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
Bytes assumes that Vec<u8>'s allocation is more than 1 byte aligned #343
Comments
As mentioned in #342 (comment), we'll start by adding an assertion that the LSB isn't set, and perhaps fix if/when some allocator actually starts handing out odd pointers. |
This comment has been minimized.
This comment has been minimized.
panic is not abort. |
So I'm reading up on
Is this saying that allocators must follow alignment requests? Such that for an alignment of say 4, the returned pointer must have the 2 LSBs set to 0? Or is the details of the address 100% opaque? |
Yes, allocators must follow alignment requirements. |
Because |
Then since |
This separates the `SharedVtable` into 3: - `PromotableEvenVtable`: The original `SharedVtable`, which will promote the `Vec` to `Shared` on the first clone, and is selected when the `Vec`'s pointer has the LSB unset. - `PromotableOddVtable`: Similar to the `PromotableEvenVtable`, but selected when the `Vec`'s pointer has the LSB set. This vtable differs in the masking used when reconstructing the `Vec`. - `SharedVtable`: This no longer checks if its current kind is `VEC` or `ARC`, and is only created by the "promotable" vtables. This also adds a test using an "odd" global allocator that purposefully bumps all pointers with alignment of 1. Closes #343
This separates the `SharedVtable` into 3: - `PromotableEvenVtable`: The original `SharedVtable`, which will promote the `Vec` to `Shared` on the first clone, and is selected when the `Vec`'s pointer has the LSB unset. - `PromotableOddVtable`: Similar to the `PromotableEvenVtable`, but selected when the `Vec`'s pointer has the LSB set. This vtable differs in the masking used when reconstructing the `Vec`. - `SharedVtable`: This no longer checks if its current kind is `VEC` or `ARC`, and is only created by the "promotable" vtables. This also adds a test using an "odd" global allocator that purposefully bumps all pointers with alignment of 1. Closes #343
This separates the `SharedVtable` into 3: - `PromotableEvenVtable`: The original `SharedVtable`, which will promote the `Vec` to `Shared` on the first clone, and is selected when the `Vec`'s pointer has the LSB unset. - `PromotableOddVtable`: Similar to the `PromotableEvenVtable`, but selected when the `Vec`'s pointer has the LSB set. This vtable differs in the masking used when reconstructing the `Vec`. - `SharedVtable`: This no longer checks if its current kind is `VEC` or `ARC`, and is only created by the "promotable" vtables. This also adds a test using an "odd" global allocator that purposefully bumps all pointers with alignment of 1. Closes #343
This separates the `SharedVtable` into 3: - `PromotableEvenVtable`: The original `SharedVtable`, which will promote the `Vec` to `Shared` on the first clone, and is selected when the `Vec`'s pointer has the LSB unset. - `PromotableOddVtable`: Similar to the `PromotableEvenVtable`, but selected when the `Vec`'s pointer has the LSB set. This vtable differs in the masking used when reconstructing the `Vec`. - `SharedVtable`: This no longer checks if its current kind is `VEC` or `ARC`, and is only created by the "promotable" vtables. This also adds a test using an "odd" global allocator that purposefully bumps all pointers with alignment of 1. Closes #343
It uses the low bit of the pointer to distinguish between KIND_VEC and KIND_ARC.
Folded over from #340
The text was updated successfully, but these errors were encountered: