Rust Compiler Team
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Libs Specializations and Unsoundness for 1.53 - "iter::Fuse is unsound with how specialization currently behaves around HRTB fn pointers" [rust#85863](https://github.com/rust-lang/rust/issues/85863) - mentioned [last week](https://github.com/rust-lang/rust/issues/85863#issuecomment-856958496) - opened by @**Frank Steffahn** - reporter suggests possible fixes, on Zulip [some more thoughts](https://rust-lang.zulipchat.com/#narrow/stream/227806-t-compiler.2Fwg-prioritization/topic/Issues.20.2385863.20and.20.2385873) - @**Josh Triplett** comments this issue will be discussed [in a follow-up T-lang meeting](https://github.com/rust-lang/rust/issues/85863#issuecomment-856958496) - "TrustedRandomAccess optimization for Zip containing vec::IntoIter is unsound with how specialization currently behaves around HRTB fn pointers" [rust#85873](https://github.com/rust-lang/rust/issues/85873) - same as above: issue will be discussed [in a follow-up T-lang meeting](https://github.com/rust-lang/rust/issues/85863#issuecomment-856958496) @**Frank Steffahn** [elaborated](https://zulip-archive.rust-lang.org/238009tcompilermeetings/52925weekly2021061054818.html#242225674): > This is indeed the case. #85975 is fixing #85969 which is a (not necessarily easy to hit) a behavioral regression introduced in beta 1.53, but no unsoundness. #85874 is about a soundness issue (#85873) that’s already present in stable, but not as old as the issue involving Fuse. That one (#85863) is, IIRC, as old as FusedIterator itself. > > > The only connection between #85874 and #85975 is that they both involve TrustedRandomAccess However, applying a simplistic sound/unsound predicate may be non-trivial. @**the8472** has made statements [like](https://github.com/rust-lang/rust/issues/85863#issuecomment-852276407): > That sounds to me like some safety loopholes around specializations on FusedIterator and Copy were not unexpected since they tend to include unsafe code. A table summarizing state proposed by Felix (aka his notes to self) Issue | Unsound | When Injected | When/if fixed -------|-----------|---------------|--------------- [#82303] | !unsound | ? ancient, <= 1.21 | ? not fixed [#85969] | !unsound | 1.53 | 1.54, PR [#85975] [#85873] | unsound | array, vec_deque in 1.53, PR [#81607]<br><br>vec believed in 1.48, PR [#70793] | no fix merged; proposed in PR [#85874] [#85863] | unsound | ancient; since Fuse intro'd? | no fix merged nor PR available [#70793]: https://github.com/rust-lang/rust/pull/70793 [#81607]: https://github.com/rust-lang/rust/issues/81607 [#82303]: https://github.com/rust-lang/rust/issues/82303 [#85863]: https://github.com/rust-lang/rust/issues/85863 [#85874]: https://github.com/rust-lang/rust/pull/85874 [#85969]: https://github.com/rust-lang/rust/issues/85969 [#85873]: https://github.com/rust-lang/rust/issues/85873 [#85975]: https://github.com/rust-lang/rust/pull/85975 ## Meeting Discussion Notes ### Definitions * **unsound:** purely safe code can cause UB because of this bug * **incorrect:** the code does not perform to specification; this could lead to UB if combined with unsafe code, or simply incorrect results with safe code ### #82303 * Affects whether `next` method is called on base iterators * when implementing `TrustedRandomAccess`, they are able to "skip ahead" where they were not before * thus side-effects from `map` calls may not be visible * This is arguably **incorrect** but not **unsound** * certainly a behavioral change * Q: Is there specified behavior in the docs? * [Zip has some docs](https://github.com/rust-lang/rust/issues/82303#issuecomment-852187787) * But in the end, does this matter? * Seems like docs do not address this question with 100% specificity ### Consensus * Backport * #85975 * #85874, the parts pertaining to `vec_deque` and `array` * Do not backport * the parts of #85874 that pertain to `Vec` * hypothetical future PRs that pertain to `Fuse` for #85863 * Why? * Backport immediate regressions that were introduced in 1.53 * 1.48 was released in Nov 2020 and that is "long enough ago" that folks may be relying on the perf optimization * Q: How much perf are we talking about? -- we don't have that data * Assumption: this is hard to weaponize or run into accidentally * Assumption: backporting with a week until release is high risk itself, so we should be minimal #### How likely are folks to hit UB in practice? Conclusion: not very likely Some comments: * I see a lot of the `zip` +/- `skip_while` and people using e.g. `map` instead of `inspect` for side effects, and Vec is **the** "canonical" collection to transform iterators into or from. * AFAICT you *need* to use HRTB function pointers or trait objects to run into *observable* UB and use subtype coercion on a `Fuse<some iterator conatining that HRTB type>` or `Zip<some iterator conatining that HRTB type>`. * the bugs here are caused by invoking next some portion of the way under one impl and then "changing horses" to the other mid-stream. I think this is pretty unlikely to hit people in practice. #### Risks of excessive backport close to release * WesleyWiser: Related to that, I'm a bit wary in general of making quick decisions the week prior to a release. The last thing we want is to introduce some kind of accidental regression in the backport to resolve an issue which has been on stable for a while and then having to ship a .1 release to fix it. * For issues introduced in 1.53, I think it definitely makes sense to prevent them from hitting stable but for issues already on stable, I think the bar is a lot higher and that increases the closer we get to release.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

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.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully