Skip to content

Miscompilation of is_whitespace inside rustc on Windows-msvc (with -Zdylib-lto) #109067

Closed

Description

@kpreid

Code

fn main() {
    println!(
        "Hello \
    • world!"
    );
}

Current output

warning: non-ASCII whitespace symbol '\u{2022}' is not skipped
 --> experiment\src\main.rs:3:16
  |
3 |           "Hello \
  |  ________________^
4 | |     • world!"
  | |     ^ non-ASCII whitespace symbol '\u{2022}' is not skipped
  | |_____|
  |

Desired output

No warning, since U+2022 "•" is not whitespace.

Anything else?

stable-x86_64-pc-windows-msvc - rustc 1.68.0 (2c8cc3432 2023-03-06)

Weirdly, this warning only occurs on Windows. Unfortunately, I have no Windows systems to test on other than GitHub Actions, so it isn't convenient to test further. I hope this bug report is useful anyway.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Mar 13, 2023
  2. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Mar 13, 2023
  3. Teapot4195 commented on Mar 13, 2023

    @Teapot4195
    Contributor

    I have a spare windows system, I'll test further once I get home

  4. ehuss commented on Mar 13, 2023

    @ehuss
    Contributor

    Hm, I can't seem to see a way to reproduce this. There isn't any platform-specific code involved in that warning. Are the logs from the GItHub Actions run publicly available?

  5. kpreid commented on Mar 13, 2023

    @kpreid
    ContributorAuthor

    Hm, I can't seem to see a way to reproduce this.

    To clarify, do you mean that you compiled the above code using a Windows system and saw no warnings?

    There isn't any platform-specific code involved in that warning.

    I'm not very familiar with Windows, but isn't it the case that Git checkout puts CRLF in text files on Windows, by default? That could have an influence while not being actually due to platform dependence in rustc, because rustc would be seeing '\\' CR LF spaces '•' instead of '\\' LF spaces '•'

    Are the logs from the GItHub Actions run publicly available?

    Yep — https://github.com/kpreid/all-is-cubes/actions/runs/4400743620/jobs/7706316716 is the run I used to test the above code. (It has a lot of other noise because it's just a quick hack upon my regular CI — if I have to I could set up a whole new repository with a custom setup.)

  6. ChrisDenton commented on Mar 13, 2023

    @ChrisDenton
    Member

    I can reproduce locally using stable msvc rustc:

    Z:\test> rustc --version --verbose
    rustc 1.68.0 (2c8cc3432 2023-03-06)
    binary: rustc
    commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
    commit-date: 2023-03-06
    host: x86_64-pc-windows-msvc
    release: 1.68.0
    LLVM version: 15.0.6
    Z:\test> cat whitespace.rs
    fn main() {
        "\
    £";
    }
    Z:\test> rustc whitespace.rs
    warning: non-ASCII whitespace symbol '\u{a3}' is not skipped
     --> whitespace.rs:2:6
      |
    2 |       "\
      |  ______^
    3 | | £";
      | | ^ non-ASCII whitespace symbol '\u{a3}' is not skipped
      | |_|
      |
    
    warning: 1 warning emitted
    
    

    Switching between Unix and Windows line endings does not seem to make a difference.

    Using windows-gnu does not have this warning. But that makes no sense to me.

  7. ChrisDenton commented on Mar 13, 2023

    @ChrisDenton
    Member

    Ok, this is super weird. It only appears to affect x86_64-msvc:

    Z:\test> rustc +1.68-i686-pc-windows-msvc whitespace.rs
    Z:\test> rustc +1.68-x86_64-pc-windows-msvc whitespace.rs
    warning: non-ASCII whitespace symbol '\u{a3}' is not skipped
     --> whitespace.rs:2:6
      |
    2 |       "\
      |  ______^
    3 | | £";
      | | ^ non-ASCII whitespace symbol '\u{a3}' is not skipped
      | |_|
      |
    
    warning: 1 warning emitted
    
  8. ehuss commented on Mar 13, 2023

    @ehuss
    Contributor

    Ah, I see, I was using aarch64-pc-windows-msvc. I tried x86_64-pc-windows-msvc, and that reproduces. How strange!

  9. ehuss commented on Mar 13, 2023

    @ehuss
    Contributor

    I did a quick bisect, and it points to #103591 as where the regression started (cc @lqd).

  10. ehuss commented on Mar 13, 2023

    @ehuss
    Contributor

    I did a little bit of poking around. Inside rustc, it definitely believes '£'.is_whitespace() is true. I don't particularly enjoy investigating inlining or llvm issues, so I probably won't poke around much more.

  11. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Mar 13, 2023
  12. 11 remaining items

  13. added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Mar 14, 2023
  14. apiraino commented on Mar 14, 2023

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-critical

  15. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Mar 14, 2023
  16. changed the title [-]Miscompilation of `is_whitespace` inside rustc on Windows-msvc (with thin-LTO)[/-] [+]Miscompilation of `is_whitespace` inside rustc on Windows-msvc (with -Zdylib-lto)[/+] on Mar 14, 2023
  17. Noratrieb commented on Mar 14, 2023

    @Noratrieb
    Member

    I've split up this issue "we have shipped a miscompiled rustc" from "-Zdylib-lto is broken on windows-msvc (#109114)" so that we can close this issue soon after the backport while still keeping track of the other one.

  18. Noratrieb commented on Mar 17, 2023

    @Noratrieb
    Member

    #108978, a crash in rusc seen by multiple people was also caused by the same issue.

  19. Mark-Simulacrum commented on Mar 21, 2023

    @Mark-Simulacrum
    Member

    If folks here could verify this is fixed on the dev-static build (https://internals.rust-lang.org/t/rust-1-68-1-pre-release-testing/18547 for instructions) that would be great - we're expecting a point release on Thursday with what is believed to be a fix.

  20. lqd commented on Mar 21, 2023

    @lqd
    Member

    There's no warning on the MCVE in the OP on 1.68.1.

  21. kpreid commented on Mar 21, 2023

    @kpreid
    ContributorAuthor

    I can confirm that the program which I originally found the problem in now compiles without the warning.

  22. mac198442 commented on Mar 26, 2023

    @mac198442

    Seems to me the entire idea of doing this for dist builds before testing it on nightly builds was a bad idea.

  23. Noratrieb commented on Mar 26, 2023

    @Noratrieb
    Member

    "dist builds" refers to all distributed builds including stable, beta, nightly and CI artifacts from master or try builds. This went through the normal nightly/beta release cycle, but apparently no one found issues there.

  24. jyn514 commented on Mar 26, 2023

    @jyn514
    Member

    I'm going to close this since we've published a 1.68.1 point release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-LTOArea: Link-time optimization (LTO)E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions