Skip to content

getShortPathName returns invalid response in Cygwin #3649

Closed

Description

@NovaDenizen

I installed Haskell Platform 8.0.1 into C:\HPlat, so gcc is at "c:\HPlat\8.0.1\mingw\bin\gcc.exe"

$ uname -a
CYGWIN_NT-6.0 myhostnameI 2.5.2(0.297/5/3) 2016-06-23 14:29 x86_64 Cygwin

$ cygpath -d "c:\\HPlat\\8.0.1\\mingw\\bin\\gcc.exe"
C:\HPlat\80227D~1.1\mingw\bin\gcc.exe

$ cygpath -l -w 'C:\HPlat\80227D~1.1\mingw\bin\gcc.exe'
C:\HPlat\8.0.1\mingw\bin\gcc.exe

$ cd ~/dl/Cabal-1.24.0.0/
$ stack repl
...much deleted...
...stribution.Version Language.Haskell.Extension> getShortPathName "c:\\HPlat\\8.0.1\\mingw\\bin\\gcc.exe"
"c:\\HPlat\\80227D~1.1"
...stribution.Version Language.Haskell.Extension>:q

$ cmd /version
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

Activity

  1. added this to the Cabal 2.0 milestone on Aug 1, 2016
  2. ezyang commented on Aug 1, 2016

    @ezyang
    Contributor

    CC @23Skidoo who wrote this code.

    Since cygpath computes short path correctly, we can look at its source code to see how to do it properly http://cygwin-ports.sourceforge.net/scan-build/utils/report-MWMmDX.html

    From GetShortPath docs:

    The path that the lpszLongPath parameter specifies does not have to be a full or long path. The short form can be longer than the specified path.

    So I guess the problem is that the sample path above shortens to something longer, violating the assumption our code makes (which allocates a buffer based on the length of the input path + 1).

  3. NovaDenizen commented on Aug 1, 2016

    @NovaDenizen
    ContributorAuthor

    Found the way to fix it from here

    Passing NULL for this parameter and zero for cchBuffer will always return the required buffer size for a specified lpszLongPath.

  4. NovaDenizen commented on Aug 1, 2016

    @NovaDenizen
    ContributorAuthor

    #3487 seems related too.

  5. ezyang commented on Aug 1, 2016

    @ezyang
    Contributor

    Thanks, I think it is indeed this bug!

  6. ezyang commented on Aug 1, 2016

    @ezyang
    Contributor

    I would close this but if we do a point release for 1.24.0.1 we should put this patch in.

  7. 23Skidoo commented on Aug 1, 2016

    @23Skidoo
    Member

    Already cherry-picked into 1.24, so closing.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions