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

getShortPathName returns invalid response in Cygwin #3649

Closed
NovaDenizen opened this issue Jul 31, 2016 · 6 comments
Closed

getShortPathName returns invalid response in Cygwin #3649

NovaDenizen opened this issue Jul 31, 2016 · 6 comments

Comments

@NovaDenizen
Copy link
Contributor

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.

@ezyang
Copy link
Contributor

ezyang commented Aug 1, 2016

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).

@NovaDenizen
Copy link
Contributor Author

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.

@NovaDenizen
Copy link
Contributor Author

#3487 seems related too.

@ezyang
Copy link
Contributor

ezyang commented Aug 1, 2016

Thanks, I think it is indeed this bug!

@ezyang
Copy link
Contributor

ezyang commented Aug 1, 2016

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

@23Skidoo
Copy link
Member

23Skidoo commented Aug 1, 2016

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
Projects
None yet
Development

No branches or pull requests

3 participants