Skip to content

Test run-pass\process-remove-from-env.rs fails on Windows with non-English locale #25268

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

Closed
petrochenkov opened this issue May 10, 2015 · 3 comments · Fixed by #25654
Closed
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. O-windows Operating system: Windows

Comments

@petrochenkov
Copy link
Contributor

https://github.com/rust-lang/rust/blob/master/src/test/run-pass/process-remove-from-env.rs

---- [run-pass] run-pass/process-remove-from-env.rs stdout ----
        thread '[run-pass] run-pass/process-remove-from-env.rs' panicked at 'called `Result::unwrap()` on an `Err` value: FromUtf8Error { bytes: [ /* some bytes */ ], error: Utf8Error { valid_up_to: 251 } }', C:/msys64/home/rust/src/libcore\result.rs:729

The failure happens in Command::spawn when the output of the command cmd /c set used in the test contains cyrillic letters. Probably some pieces of process use locale-dependent encoding (Windows-1251 in this case) instead of unicode. Changing the system locale to English (USA) or replacing cmd with something like echo foo makes this error go away.

cc @alexcrichton

@steveklabnik steveklabnik added the O-windows Operating system: Windows label May 10, 2015
@alexcrichton
Copy link
Member

Hm interesting! This probably isn't so much connected to locales so much that something in the environment/output isn't valid UTF-8. Could you get a backtrace of this failure? I would be surprised if this was coming from std::process, but the test looks pretty innocuous, so it may very well be coming from std!

@petrochenkov
Copy link
Contributor Author

The problem may actually reside in compiletest, it captures the output of the test and then can interpret it incorrectly. If the test is run as a standalone program outside of the test suite then no panic happens and the test works as expected. I'm still investigating.

Here's the backtrace, but it's not very helpful:

stack backtrace:
   1:         0x711bd332 - sys::backtrace::write::h022859084c97c7d8kss
   2:         0x711c7a03 - rt::unwind::register::hf6cf68ec3d65cb61gZv
   3:         0x71185274 - rt::unwind::begin_unwind_inner::ha0de919eeab7aca9qWv
   4:         0x71185dd7 - rt::unwind::begin_unwind_fmt::hf37080597d178e4bwVv
   5:         0x711c7670 - rust_begin_unwind
   6:         0x711e0732 - panicking::panic_fmt::h705ebd4b98819809PJy
   7:           0x402d6d
   8:           0x4277a9
   9:           0x422aae
  10:           0x414e7a
  11:           0x40af03
  12:           0x44a4c0 - main
  13:         0x6d7a91ad - Bencher::ns_per_iter::he7122ff52105191f77b
  14:         0x6d7a70bd - Bencher::ns_per_iter::he7122ff52105191f77b
  15:         0x71201d0c - rust_try
  16:         0x71201ce9 - rust_try
  17:         0x6d7a737e - Bencher::ns_per_iter::he7122ff52105191f77b
  18:         0x711c5936 - sys::process::Command::cwd::hd77e7bf8cfdcbde1DGu
  19:         0x773f59cd - BaseThreadInitThunk


failures:
    [run-pass] run-pass/process-remove-from-env.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured

thread '<main>' panicked at 'Some tests failed', C:/msys64/home/rust/src/compiletest/compiletest.rs:256
stack backtrace:
   1:         0x711bd332 - sys::backtrace::write::h022859084c97c7d8kss
   2:         0x711c7c17 - rt::unwind::register::hf6cf68ec3d65cb61gZv
   3:         0x71185274 - rt::unwind::begin_unwind_inner::ha0de919eeab7aca9qWv
   4:           0x4039f5
   5:           0x4417bb
   6:         0x71201d0c - rust_try
   7:         0x71201ce9 - rust_try
   8:         0x711c899a - rt::lang_start::hf4cd440969ce39bd98v
   9:           0x4013e8
  10:           0x40151b
  11:         0x773f59cd - BaseThreadInitThunk

@alexcrichton
Copy link
Member

Aha! It looks like you are 100% correct.

I suspect it would be fine for compiletest to just use from_utf8_lossy

@alexcrichton alexcrichton added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-testsuite Area: The testsuite used to check the correctness of rustc labels May 11, 2015
bors added a commit that referenced this issue Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. O-windows Operating system: Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants