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

[std] Osstr lossy example #56142

Merged
merged 1 commit into from Dec 14, 2018

Conversation

Projects
None yet
7 participants
@jnqnfe
Contributor

jnqnfe commented Nov 21, 2018

No description provided.

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 21, 2018

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Nov 22, 2018

Thanks for the PR! Can this be implemented as an example without making it memory unsafe though? As-is this is susceptible to future breakage because the example itself is exhibiting memory unsafety.

@jnqnfe

This comment has been minimized.

Contributor

jnqnfe commented Nov 28, 2018

Thanks for the PR! Can this be implemented as an example without making it memory unsafe though? As-is this is susceptible to future breakage because the example itself is exhibiting memory unsafety.

The only options are (as far as I can see)
a) doing it the way I have, via an unchecked String
b) transmuting a byte array, which I'd assume you'd object to more
c) splitting the example to work differently on different platforms, to take advantage of the from-byte-slice unix extension method, which would be a mess

otherwise the OsStr methods in std would need to be extended to provide a cleaner solution

fyi, this and a couple of other similar push requests were a precursor to a further push request to extend OsStr handling in std to allow splitting, as needed by an upcoming v2.0 of my cmd-line arg parsing library (which is currently having to transmute). I started investigating how best to implement that, but never got around to finishing. The best solution for that would likely be to just open up from/to byte array methods, perhaps with method names like to_storage_byes to try to help reinforce the message that OsStr does not store the string in the OS form on some platforms.

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Nov 28, 2018

Yes to implement this the best way would be via the OS extension traits such as OsStr::from_bytes on Unix.

@Aaronepower

This comment has been minimized.

Contributor

Aaronepower commented Dec 10, 2018

Triage; @jnqnfe Hello, have you been able to get back to this PR?

@jnqnfe jnqnfe force-pushed the jnqnfe:osstr_lossy_example branch from d89c4d0 to 0008e0d Dec 12, 2018

@jnqnfe

This comment has been minimized.

Contributor

jnqnfe commented Dec 12, 2018

@Aaronepower @alexcrichton Yes, sorry for the delay, I'm largely working offline with no internet from home.

I've reworked the change as suggested. I also fixed it so that it will actually work correctly on Windows, having corrected a misunderstanding from not examining closely enough what the Windows/WTF-8 to-lossy code was doing.

@alexcrichton

This comment has been minimized.

Member

alexcrichton commented Dec 12, 2018

@bors: r+

Looks good to me, thanks!

@bors

This comment has been minimized.

Contributor

bors commented Dec 12, 2018

📌 Commit 0008e0d has been approved by alexcrichton

@bors

This comment has been minimized.

Contributor

bors commented Dec 13, 2018

⌛️ Testing commit 0008e0d with merge 9d1f8f1...

bors added a commit that referenced this pull request Dec 13, 2018

@bors

This comment has been minimized.

Contributor

bors commented Dec 13, 2018

💔 Test failed - status-travis

@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Dec 13, 2018

The job dist-i686-freebsd of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Building stage2 tool cargo (i686-unknown-freebsd)
[01:08:29]  Downloading crates ...
[01:08:49] warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:09] warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:29] error: failed to download from `https://crates.io/api/v1/crates/openssl-src/111.1.0+1.1.1a/download`
[01:09:29] Caused by:
[01:09:29]   [6] Couldn't resolve host name (Could not resolve host: crates.io)
[01:09:29] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "i686-unknown-freebsd" "-j" "4" "--release" "--locked" "--color" "always" "--manifest-path" "/checkout/src/tools/cargo/Cargo.toml" "--features" "rustc-workspace-hack/all-static" "--message-format" "json"
[01:09:29] expected success, got: exit code: 101
---
travis_time:end:22f3fd00:start=1544685027560141474,finish=1544685027571474577,duration=11333103
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0ed8d9f4
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:07bdec5d
travis_time:start:07bdec5d
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0161be90
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@kennytm

This comment has been minimized.

Member

kennytm commented Dec 13, 2018

kennytm added a commit to kennytm/rust that referenced this pull request Dec 13, 2018

bors added a commit that referenced this pull request Dec 13, 2018

Auto merge of #56775 - kennytm:rollup, r=kennytm
Rollup of 34 pull requests

Successful merges:

 - #56142 ([std] Osstr lossy example)
 - #56203 (Add lint for items deprecated in future)
 - #56343 (Remove not used mod)
 - #56351 (Stabilize `linker-flavor` flag.)
 - #56439 (Clearer error message for dead assign)
 - #56490 (Add checked_add method to Instant time type)
 - #56507 (polonius tweaks)
 - #56562 (Update libc version required by rustc)
 - #56600 (bootstrap: fix edition)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56637 (rustdoc: Fix local reexports of proc macros)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56672 (Document time of back operations of a Linked List)
 - #56677 (#[must_use] on traits in stdlib)
 - #56679 (overhaul external doc attribute diagnostics)
 - #56691 (fix install broken link)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56710 (Always set the RDRAND and RDSEED features on SGX)
 - #56713 (Test capacity of ZST vector)
 - #56718 (Use libbacktrace pretty-printing)
 - #56725 (fix rust-lang/rust issue #50583)
 - #56731 (Add missing urls in ffi module docs)
 - #56738 (Fix private_no_mangle_fns message grammar)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56746 (Add test of current behavior (infer free region within closure body))
 - #56747 (target: remove Box returned by get_targets)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56755 (Account for `impl Trait` when suggesting lifetime)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56758 (Add short emoji status to toolstate updates)
 - #56783 (Add `--pinentry-mode=loopback` to deployment script)

@jnqnfe jnqnfe referenced this pull request Dec 13, 2018

Open

Lossy consistency #56787

bors added a commit that referenced this pull request Dec 13, 2018

Auto merge of #56775 - kennytm:rollup, r=kennytm
Rollup of 32 pull requests

Successful merges:

 - #56142 ([std] Osstr lossy example)
 - #56203 (Add lint for items deprecated in future)
 - #56343 (Remove not used mod)
 - #56351 (Stabilize `linker-flavor` flag.)
 - #56439 (Clearer error message for dead assign)
 - #56507 (polonius tweaks)
 - #56562 (Update libc version required by rustc)
 - #56600 (bootstrap: fix edition)
 - #56609 (Unconditionally emit the target-cpu LLVM attribute.)
 - #56637 (rustdoc: Fix local reexports of proc macros)
 - #56658 (Add non-panicking `maybe_new_parser_from_file` variant)
 - #56672 (Document time of back operations of a Linked List)
 - #56677 (#[must_use] on traits in stdlib)
 - #56679 (overhaul external doc attribute diagnostics)
 - #56691 (fix install broken link)
 - #56695 (Fix irrefutable matches on integer ranges)
 - #56699 (Use a `newtype_index!` within `Symbol`.)
 - #56702 ([self-profiler] Add column for percent of total time)
 - #56708 (Remove some unnecessary feature gates)
 - #56710 (Always set the RDRAND and RDSEED features on SGX)
 - #56713 (Test capacity of ZST vector)
 - #56718 (Use libbacktrace pretty-printing)
 - #56725 (fix rust-lang/rust issue #50583)
 - #56731 (Add missing urls in ffi module docs)
 - #56738 (Fix private_no_mangle_fns message grammar)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56746 (Add test of current behavior (infer free region within closure body))
 - #56747 (target: remove Box returned by get_targets)
 - #56749 (x86: Add the `adx` target feature to whitelist)
 - #56755 (Account for `impl Trait` when suggesting lifetime)
 - #56756 (Disable btree pretty-printers on older gdbs)
 - #56758 (Add short emoji status to toolstate updates)
@bors

This comment has been minimized.

Contributor

bors commented Dec 13, 2018

⌛️ Testing commit 0008e0d with merge 5900dae...

bors added a commit that referenced this pull request Dec 13, 2018

@bors

This comment has been minimized.

Contributor

bors commented Dec 14, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 5900dae to master...

@bors bors merged commit 0008e0d into rust-lang:master Dec 14, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment