golang / go

The Go programming language

Home Page:https://go.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

josephpaul0 opened this issue · comments

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

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

It seems a regression of f108158

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