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

extra::test::test_lots_of_files appears to fail if there are any non-utf8 file names in the top 4 sublevels of / #9406

Closed
huonw opened this issue Sep 22, 2013 · 7 comments

Comments

@huonw
Copy link
Member

huonw commented Sep 22, 2013

It runs glob("/*/*/*/*").skip(10000), which traverses a lot of files and if any of them have non utf8 names, this fails the is_utf8 assertion (presumably when constructing the path).

@alexcrichton
Copy link
Member

if str::from_utf8 raised on a condition instead, this would be a pretty good instance to return "Just terminate the string" and then processing could go as normal.

I'm not entirely sure what the status of that is, though.

@thestinger
Copy link
Contributor

It shouldn't silently fail to work if there are non-UTF-8 file paths. Assuming all paths can be stored in strings is incorrect on Rust's part. It's not true on Windows either, because NTFS uses UCS2 and doesn't enforce valid Unicode.

@alexcrichton
Copy link
Member

Oh yeah this test specifically would ignore the condition, but the condition handler wouldn't be installed by default by the glob function.

@lilyball
Copy link
Contributor

This should be covered by #7225.

@flaper87
Copy link
Contributor

Based on the result of the proposed PR, this is still an issue.

@flaper87
Copy link
Contributor

Complete test case for this issue

    #[test]
    #[cfg(not(windows))]
    fn test_non_utf8_glob() {
        let dir = tempfile::TempDir::new("").unwrap();
        let p = dir.path().join(&[0xFFu8]);
        fs::mkdir(&p, S_IRWXU as u32);

        let pat = p.with_filename("*");
        assert_eq!(glob(pat.as_str().expect("tmpdir is not utf-8")).collect::<~[Path]>(), ~[p])
    }

@lilyball
Copy link
Contributor

I have filed a new issue specifically about glob() and non-utf8 files, which is the root cause of this one, as #11916. Closing this in favor of that.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 9, 2022
Correctly handle unescape warnings

fixes rust-lang#9405

changelog: Fix ICE when format literals raise compiler warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants