Skip to content

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

@josephpaul0

Description

@josephpaul0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions