go: os: spurious TestDirFS failures due to directory mtime skew on Windows
https://storage.googleapis.com/go-build-log/f31194a9/windows-386-2008_061172ea.log:
--- FAIL: TestDirFS (0.35s)
os_test.go:2690: TestFS found errors:
testdata/simple: mismatch:
entry.Info() = simple IsDir=true Mode=drwxrwxrwx Size=0 ModTime=2020-11-16 02:32:02.0111083 +0000 GMT
file.Stat() = simple IsDir=true Mode=drwxrwxrwx Size=0 ModTime=2020-11-16 02:32:02.012085 +0000 GMT
FAIL
FAIL os 2.635s
Marking as release-blocker for Go 1.16 because DirFS is a new API.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 50 (36 by maintainers)
Commits related to this issue
- [dev.regabi] os: disable TestDirFS until #42637 is fixed This test is causing nearly every trybot run on dev.regabi and dev.typeparams to fail. It's already a release blocker for Go 1.16, so the fail... — committed to golang/go by mdempsky 3 years ago
- [dev.regabi] all: merge master (bf0f7c9) into dev.regabi This merge involved two merge conflicts: 1. walk's ascompatee code has been substantially refactored on dev.regabi, so CL 285633 is ported to... — committed to golang/go by mdempsky 3 years ago
- [dev.typeparams] all: merge dev.regabi (5e4a0cd) into dev.typeparams Merge List: + 2021-01-25 5e4a0cdde3 [dev.regabi] all: merge master (bf0f7c9) into dev.regabi + 2021-01-25 bf0f7c9d78 doc/go1.16: ... — committed to golang/go by mdempsky 3 years ago
- [dev.boringcrypto] all: merge master (2f0da6d) into dev.boringcrypto Manual edits in src/cmd/compile/internal/reflectdata/reflect.go to keep build working. Merge List: + 2021-02-17 2f0da6d9e2 go/ty... — committed to golang/go by rsc 3 years ago
- [dev.fuzz] all: merge master (7764ee5) into dev.fuzz Conflicts: - api/next.txt Merge List: + 2021-02-19 7764ee5614 runtime: fix invalid nil g check for for mips64x + 2021-02-19 87f425da14 cmd/go/i... — committed to golang/go by katiehockman 3 years ago
- windows: comment on fields omitted from the win32finddata1 struct Updates golang/go#42637 Change-Id: I2e8c95af3cf2172c55bda6a15a749afcc6c45581 Reviewed-on: https://go-review.googlesource.com/c/sys/+... — committed to golang/sys by bcmills 3 years ago
- syscall: comment on fields omitted from the win32finddata1 struct Updates #42637 Change-Id: I4c7d38034b60c2c04efdeb530a97d96deddfd6fe Reviewed-on: https://go-review.googlesource.com/c/go/+/284152 Tr... — committed to golang/go by bcmills 3 years ago
It looks like there are two paths in the builder (CC @dmitshur to confirm/deny) – one that writes a “snapshot” and one that writes the actual Go source. It looks like these might be coming from very different places. In that case, I wonder if there’s an effect on this snippet of the untarring code:
Maybe the mtime is 0 for the tarballs sent by the trybots, but not the other ones, and os.Chtimes is helping sync back the timestamp to the MFT a bit sooner.
Change https://golang.org/cl/285720 mentions this issue:
os: force mock mtime before running fstest on directory on WindowsAlright, here’s an analogous example reproducer for directories:
And here’s the bug being triggered:
@egonelbre,
ExampleWriteFilehas no// Outputcomment, so it should not actually be executed — search for “Example functions without output comments” in https://tip.golang.org/pkg/testing/#hdr-Examples.(If it were actually run, that would need to be fixed separately; see #28387 and #30316.)
This didn’t work at all. It looks like nothing else writes to those files anyway, in order to cause the problem.
I wonder if git is being shim’d by Defender that then keeps the file handle open somehow after the process has terminated?
Oddly, the
syscall.win32finddata1struct being passed to theFindNextFileWsystem call seems to be three fields short: it is missing thedwFileType,dwCreatorType, andwFinderFlagsfields from theWIN32_FIND_DATAWstructure.Is that a secondary bug?
Looking at the implementation of the test, it’s either a problem with the test itself, with the new
testing/fstestpackage, or both. Right now, I’m leaning toward this being a problem withos.TestDirFSproper.It appears that
fstest.TestFSassumes that no file or directory in the givenfs.FSis changed in any way while the test is running, but thenos.TestDirFSis runningTestFSon the directory containing theos/signalpackage. That causes the test for theospackage to fail if there are any concurrent changes in theos/signalpackage.I don’t know why the directory’s
ModTimewas being changed at all in the CL at which this failure was observed; that may be a peripherally-related bug ingo run.However, I could quite easily imagine someone running
go test oswhile concurrently editing an otherwise-unrelated source file inos/signal(such as a test function for that package), and in that situation I could easily envisionos.TestDirFSspuriously failing.If
os.TestDirFSrequires the property that the directory it is traversing does not change at all while the test is running, it should either have its own isolated subdirectory ofGOROOT/src/os/testdata, or it should construct its own temporary directory for the duration of the test and runfstest.TestFSon that — not on thesignalsubdirectory.