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

os: Lstat from Go 1.12.x returns empty filename for C:\pagefile.sys on Windows #30883

Closed
josephpaul0 opened this issue Mar 16, 2019 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows

Comments

@josephpaul0
Copy link

There seem to be a regression in os.Lstat(path) function in Go 1.12 on Windows when path is "pagefile.sys" on C:\.
The behaviour is correct with Go 1.8.7.

What version of Go are you using (go version)?

go version go1.12.1 windows/amd64
go version go1.12 windows/amd64

Does this issue reproduce with the latest release?

Yes, go1.12.1 is the latest release

What operating system and processor architecture are you using (go env)?

go env Output
set GOARCH=amd64
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64

What did you do?

err := os.Chdir("C:\\")
fi, err := os.Lstat("pagefile.sys")
if fi.Name() == "" {
	fmt.Println("The bug is present.")
} else {
	fmt.Println("This program works correctly.")
}

Compile and run this on Windows 7 or Windows 10 amd64:
https://play.golang.org/p/ewOhJ7ErXf5

Use Go 1.12.1, then compile again with Go 1.8.7 and see the difference.

What did you expect to see?

The filename should be "pagefile.sys"

What did you see instead?

The filename is empty with Go 1.12

@odeke-em odeke-em changed the title [windows] os.Lstat from Go 1.12.x returns empty filename for C:\pagefile.sys os: Lstat from Go 1.12.x returns empty filename for C:\pagefile.sys on Windows Mar 17, 2019
@odeke-em
Copy link
Member

Thank you for this report @josephpaul0 and welcome to the Go project!

So you mention that this is a regression from Go1.8.7, have you tried Go1.11 or other versions?

I shall kindly page some related folks @alexbrainman @ianlancetaylor @jordanrh1

@odeke-em odeke-em added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows labels Mar 17, 2019
@cuonglm
Copy link
Member

cuonglm commented Mar 17, 2019

It seems a regression of f108158

@gopherbot
Copy link

Change https://golang.org/cl/167779 mentions this issue: os: fix windows Lstat missing name for some files

@golang golang locked and limited conversation to collaborators Mar 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

4 participants