Skip to content
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

from_u32_unchecked: check validity, and fix UB in Wtf8 #72683

Merged
merged 5 commits into from
May 31, 2020

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 28, 2020

Fixes #72760

@rust-highfive
Copy link
Collaborator

r? @withoutboats

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 28, 2020
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented May 28, 2020

📌 Commit 1956ada4c855673de327f16c91d11fdc4cd5a39c has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2020
@RalfJung
Copy link
Member Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 28, 2020
@RalfJung RalfJung removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 29, 2020
@RalfJung
Copy link
Member Author

@Mark-Simulacrum I fixed the endless recursion.

@RalfJung RalfJung added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2020
@RalfJung
Copy link
Member Author

r? @Mark-Simulacrum
(sorry for double-ping)

@Mark-Simulacrum
Copy link
Member

@bors r+

No worries!

@bors
Copy link
Contributor

bors commented May 29, 2020

📌 Commit 52ed89a has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 29, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request May 29, 2020
…imulacrum

from_u32_unchecked: check validity when debug assertions are enabled
@RalfJung
Copy link
Member Author

This actually caused CI to fail in #72736 (comment)

---- sys_common::wtf8::tests::wtf8_as_str stdout ----
thread 'sys_common::wtf8::tests::wtf8_as_str' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/char/convert.rs:102:33

---- sys_common::wtf8::tests::wtf8_code_points stdout ----
thread 'sys_common::wtf8::tests::wtf8_code_points' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/char/convert.rs:102:33

...

@bors r-

Our wtf8 code seems to have UB.^^

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 29, 2020
@RalfJung RalfJung changed the title from_u32_unchecked: check validity when debug assertions are enabled from_u32_unchecked: check validity, and fix UB in Wtf8 May 30, 2020
@RalfJung
Copy link
Member Author

@SimonSapin I implemented the fix you suggested here.

@RalfJung RalfJung added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 30, 2020
@Mark-Simulacrum
Copy link
Member

r=me with comment added, unless you want to wait for @SimonSapin's review in particular (but AFAICT this is just moving some code around so I feel comfortable approving)

@RalfJung
Copy link
Member Author

I added comments but tried to avoid claiming that this is valid UTF-8... what do you think?

src/libcore/char/methods.rs Outdated Show resolved Hide resolved
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

@RalfJung
Copy link
Member Author

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented May 30, 2020

📌 Commit 0fb6e63 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2020
@dtolnay dtolnay added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 30, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request May 31, 2020
…imulacrum

from_u32_unchecked: check validity, and fix UB in Wtf8

Fixes rust-lang#72760
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#72683 (from_u32_unchecked: check validity, and fix UB in Wtf8)
 - rust-lang#72715 (Account for trailing comma when suggesting `where` clauses)
 - rust-lang#72745 (generalize Borrow<[T]> for Interned<'tcx, List<T>>)
 - rust-lang#72749 (Update stdarch submodule to latest head)
 - rust-lang#72781 (Use `LocalDefId` instead of `NodeId` in `resolve_str_path_error`)

Failed merges:

r? @ghost
@bors bors merged commit 3bbb475 into rust-lang:master May 31, 2020
bors added a commit to rust-lang/miri that referenced this pull request May 31, 2020
test WTF8 encoding corner cases

This adds a Miri-side test for rust-lang/rust#72760.

Blocked on rust-lang/rust#72683.
@RalfJung RalfJung deleted the char-debug-check branch June 1, 2020 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OsString::from_wide (in Windows OsStringExt) is unsound
8 participants