Skip to content

Bug: PowerShell cannot handle a file with long non-ascii file name #13551

Closed

Description

@hez2010

Steps to reproduce

Create a directory named "Test"
In the directory, create a file named "测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试.txt"

cd Test
ls

Expected behavior

Files listed normally.

Actual behavior

out-lineoutput: startIndex cannot be larger than length of string. (Parameter 'startIndex')

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.20201
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Aug 31, 2020
  2. changed the title [-]out-lineoutput: startIndex cannot be larger than length of string[/-] [+]PowerShell cannot handle a file with long file name[/+] on Aug 31, 2020
  3. changed the title [-]PowerShell cannot handle a file with long file name[/-] [+]PowerShell cannot handle a file with long non-ascii file name[/+] on Aug 31, 2020
  4. changed the title [-]PowerShell cannot handle a file with long non-ascii file name[/-] [+]Bug: PowerShell cannot handle a file with long non-ascii file name[/+] on Aug 31, 2020
  5. iSazonov commented on Aug 31, 2020

    @iSazonov
    Collaborator

    /cc Dongbo Wang (@daxian-dbw) Can you reproduce?

  6. daxian-dbw commented on Aug 31, 2020

    @daxian-dbw
    Member

    I cannot reproduce. I guess it's related to the buffer width/height that was being used. Steve (@hez2010) can you share your buffer width/height when seeing the issue?

  7. hez2010 commented on Sep 1, 2020

    @hez2010
    ContributorAuthor

    You can resize and reduce the width of window.

    image

  8. xtqqczze commented on Sep 4, 2020

    @xtqqczze
    Contributor

    I also cannot reproduce using Windows Terminal v1.2.2381.0 on Windows 10.0.19041 (2004).

    Steve (@hez2010) Does this issue occur when not using Windows Terminal?

  9. hez2010 commented on Sep 5, 2020

    @hez2010
    ContributorAuthor

    xtqqczze Yes
    Additional information: my language and region was set to ja-jp.

    And my PSReadLine is 2.1.0-beta2

  10. iSazonov commented on Sep 5, 2020

    @iSazonov
    Collaborator

    And my PSReadLine is 2.1.0-beta2

    Do you see the issue without PSReadline?

  11. hez2010 commented on Sep 6, 2020

    @hez2010
    ContributorAuthor

    Ilya (@iSazonov) Yes, the issue still exists

    Here is normal view of the error:
    image

  12. iSazonov commented on Jan 18, 2021

    @iSazonov
    Collaborator
  13. DHowett commented on Jan 18, 2021

    @DHowett

    We’ll need a backtrace or a repro outside of Terminal to be sure. A repro outside of terminal would require setting the buffer size to be the same as the window size (no scrollback history)

  14. hez2010 commented on Jan 21, 2021

    @hez2010
    ContributorAuthor

    I've hit asset failure while debugging pwsh (with no modules enabled):
    image

    Failed for str.Length < offset cannot be fullfilled:
    image

    Where str is "测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试.txt", and culture is ja-JP.

    pwsh version: PowerShell 7.2.0-preview.2-52-gc406f9fe68b7bee1bc4695f70d9dba86b3061ad4

  15. iSazonov commented on Jan 21, 2021

    @iSazonov
    Collaborator

    Steve (@hez2010) I suggest to look previous callsites in the debug, maybe GenerateLinesWithoutWordWrap().

  16. hez2010 commented on Jan 21, 2021

    @hez2010
    ContributorAuthor

    Ilya (@iSazonov) In GenerateLinesWithoutWordWrap:

    image

    image

  17. iSazonov commented on Jan 24, 2021

    @iSazonov
    Collaborator

    Steve (@hez2010) Do you think I can debug by means of screenshots? 😄 If you already run debugger you could review step by step 2-3 method levels and find a root of the issue.

  18. iSazonov commented on Jan 25, 2021

    @iSazonov
    Collaborator

    We split a line to fit in a window width and if on last iteration we did get zero length tail we did next iteration but we should stop.
    Proposed fix iSazonov@6a9bf10
    I added some cleanups to make the code more reliable.

    If anyone wants, they can add tests and pull PR.

  19. added
    Issue-BugIssue has been identified as a bug in the product
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    and removed
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Jan 25, 2021
  20. hez2010 commented on Jan 25, 2021

    @hez2010
    ContributorAuthor

    I can confirm that the commit iSazonov/PowerShell@6a9bf10 can fix this issue.

  21. kasini3000 commented on Apr 15, 2021

    @kasini3000

    interesting.
    In win terminal, I cannot reproduce the problem.
    In pwsh.exe, I reproduced the problem.
    PowerShell 7.2.0-preview.4 ,win10

  22. iSazonov commented on Apr 15, 2021

    @iSazonov
    Collaborator

    kasini3000 Please check with v7.2.0-preview.5

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

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Interactive-Consolethe console experience

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions