This week's topic: Weak refcounted pointers, dangling, alignment, and long-term implications for custom DSTs.
Lang: nikomatsakis, josh, pnkfelix, scottmcm, cramertj
Guests: Christopher Durham (presenter), Mark, Amanieu
into_raw
and from_raw
available for unsized types https://github.com/rust-lang/rust/pull/80407Weak::into_raw
and Weak::from_raw
to produce dangling Weak<T>
pointers due to unsizing coercions:
let ptr: Weak<[u8]> = Weak::<[u8; 32]>::new();
Weak::from_raw(Weak::into_raw(ptr));
[u8]
and dyn Trait
, but does it suffice for custom DST?Weak::from_raw
so that it does not care about the alignmentWeak::from_raw_unsized
that takes the alignment as an extra parameterWeak::from_raw
with unsized
Weak
is that the data it references may not be valid (may have been dropped)
Layout
Weak
to store the layout, but that would mean extra fields in every Rc
, which seems like a non-starterWeak
in some formWeak::from_raw
: need to be able to get alignment without a valid data pointer
DynSized
trait
size_of_val
and align_of_val
with a dropped valuealign_of_val
to require a valid-but-dropped value?Weak::from_raw
to check for the sentinel value, since that may not be valid-but-dropped
if ptr == 0xFFFF_FFFF_FFFF_FFFF
…[ ref count data] <-- from_raw must recover pointer to this
[ padding ]
[ payload ] <-- into_raw gives pointer to this
align_of_val_raw
require a once-valid-but-dropped value, in order to better support thin objects
align_of_val_raw
is only ever invoked on once-valid-but-dropped valuesalign_of_val_raw
to be forced to work for metadata + thin pointerfrom_raw
to check for sentinel and take some special action if it is observed
Rc
/Arc
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Syncing