Title: `.map_unchecked_mut()` is unsound for self-referential types · Issue #9 · microsoft/stackfuture · GitHub
Open Graph Title: `.map_unchecked_mut()` is unsound for self-referential types · Issue #9 · microsoft/stackfuture
X Title: `.map_unchecked_mut()` is unsound for self-referential types · Issue #9 · microsoft/stackfuture
Description: Hi! I’ve recently created a similar crate, but without dynamic dispatch and with automatic size calculation and Send/Sync inference, and found a problem with using .map_unchecked_mut() in .poll(). This line: https://github.com/microsoft/...
Open Graph Description: Hi! I’ve recently created a similar crate, but without dynamic dispatch and with automatic size calculation and Send/Sync inference, and found a problem with using .map_unchecked_mut() in .poll(). ...
X Description: Hi! I’ve recently created a similar crate, but without dynamic dispatch and with automatic size calculation and Send/Sync inference, and found a problem with using .map_unchecked_mut() in .poll(). ...
Opengraph URL: https://github.com/microsoft/stackfuture/issues/9
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`.map_unchecked_mut()` is unsound for self-referential types","articleBody":"Hi! I’ve recently created [a similar crate](https://github.com/GoldsteinE/name-it), but without dynamic dispatch and with automatic size calculation and Send/Sync inference, and found [a problem](https://github.com/GoldsteinE/name-it/issues/11) with using `.map_unchecked_mut()` in `.poll()`.\r\n\r\nThis line:\r\n\r\nhttps://github.com/microsoft/stackfuture/blob/ae58939/src/lib.rs#L207\r\n\r\ncauses a retag of the whole byte array, invalidating all internal references inside of a future. To prevent this, you should directly transmute `Pin\u003c\u0026mut MaybeUninit[u8; _]\u003e` instead of mapping.\r\n\r\nThis is a simple testcase that fails under Miri (adapted from `futures-rs` test suite):\r\n\r\n```rust\r\nuse futures::{\r\n channel::mpsc,\r\n executor::block_on,\r\n sink::SinkExt as _,\r\n stream::{Stream, StreamExt as _},\r\n};\r\nuse stackfuture::StackFuture;\r\nuse std::thread;\r\n\r\n#[test]\r\nfn stress_drop_sender() {\r\n const ITER: usize = if cfg!(miri) { 100 } else { 10000 };\r\n\r\n fn list() -\u003e impl Stream\u003cItem = i32\u003e {\r\n let (tx, rx) = mpsc::channel(1);\r\n thread::spawn(move || {\r\n block_on(send_one_two_three(tx));\r\n });\r\n rx\r\n }\r\n\r\n for _ in 0..ITER {\r\n let v: Vec\u003c_\u003e = block_on(list().collect());\r\n assert_eq!(v, vec![1, 2, 3]);\r\n }\r\n}\r\n\r\nfn send_one_two_three(mut tx: mpsc::Sender\u003ci32\u003e) -\u003e StackFuture\u003c'static, (), 512\u003e {\r\n StackFuture::from(async move {\r\n for i in 1..=3 {\r\n tx.send(i).await.unwrap();\r\n }\r\n })\r\n}\r\n```","author":{"url":"https://github.com/GoldsteinE","@type":"Person","name":"GoldsteinE"},"datePublished":"2022-08-12T06:51:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/9/stackfuture/issues/9"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:31918b14-9a36-d663-703e-4d3d1285f199 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1DC:2088C9:5AA736:79DD12:6A629226 |
| html-safe-nonce | 35758b007a4857de8cfce554add794d23291fe434cab05b2837c11fc644e42dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMURDOjIwODhDOTo1QUE3MzY6NzlERDEyOjZBNjI5MjI2IiwidmlzaXRvcl9pZCI6IjY3NjEzMTIyMDgzNTI4NzUwNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0799ac1e8f10b2d55cc37c5fbe834b7a333293621d6a9084c505365cf90ee3b4 |
| hovercard-subject-tag | issue:1336823285 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/stackfuture/9/issue_layout |
| twitter:image | https://opengraph.githubassets.com/08dc91a413756fc3b1865d2c92edcdfdf936adcd44df843a40b003dcee53c218/microsoft/stackfuture/issues/9 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/08dc91a413756fc3b1865d2c92edcdfdf936adcd44df843a40b003dcee53c218/microsoft/stackfuture/issues/9 |
| og:image:alt | Hi! I’ve recently created a similar crate, but without dynamic dispatch and with automatic size calculation and Send/Sync inference, and found a problem with using .map_unchecked_mut() in .poll(). ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GoldsteinE |
| hostname | github.com |
| expected-hostname | github.com |
| None | ac2209d8cb6970a1bd08cb0a3f821d7166ac544c2ca1c87819c335bb84310ecd |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/stackfuture git https://github.com/microsoft/stackfuture.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 515774180 |
| octolytics-dimension-repository_nwo | microsoft/stackfuture |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 515774180 |
| octolytics-dimension-repository_network_root_nwo | microsoft/stackfuture |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2fca8cd598678aaa64706088ad13b4e19177e108 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width