-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: race condition between (*os.File).Stat and os.Chdir on windows #13752
Comments
CL https://golang.org/cl/18181 mentions this issue. |
FWIW, it is always nice to include the actual output from the program along with what you expected. I cannot easily reproduce, since I don't have a Windows machine handy. (And maybe my Windows machine behaves differently from yours.) |
I've edited it. |
Why? Alex |
(*os.File).Stat() should return a os.FileInfo of the file we opened, see https://github.com/golang/go/blob/master/src/os/stat_windows.go#L23 if file.name is given as relative path, the problem is occurred. see also my CL. Thank you. hiro |
What is that problem? I don't see how those internal bits that your CL changes affect anything. Can you point me to an example that demonstrates that problem? Thank you. Alex |
Hmm, I don't understand what you mean. Do you try the code above? What output you get? Thank you. hiro |
I didn't not. I disagree with your report. You say "First and second line should be the same.", but I don't see why the two lines shouldn't be different. Your output display internal state of os package. Where does it say that this internal state should be one way or other? Unless you can demonstarte that this internal state affects something visible to os package user, I don't see how this is a bug. Alex |
From my understanding, I hope os package provide platform-independent interface. Although it's a corner case for you, I think this is a bug. |
Which File.Stat behavior does not meat your expectations? Please provide an example to demonstrate. Just complaining about File.Stat internal state gets us nowhere. Internal state is not behavior. Alex |
I don't care the internal state, too. I say:
Thank you. hiro |
Sorry about my poor English. |
I am sorry, but I don't see anything broken here. You don't need to explain me why something is broken, you need to provide a small program to demonstrate broken behaviour. Program that outputs something undocumented or unexpected. Alex |
Is this mean, you tried my code above? or another way? |
@alexbrainman, I understand his bug report at least. See the CL's test: https://go-review.googlesource.com/#/c/18181/4/src/os/os_windows_test.go |
Maybe, we talked about the difference between equality and identity... |
@bradfitz, are you saying that it is important that reflect.DeepEqual(fi, fi2) is true in new test in CL 18181? If yes, then why? If no, then what are we fixing here? Alex |
(*os.File).Stat is stat not fstat. And the FileInfo is created from name given Open(). https://github.com/golang/go/blob/master/src/os/stat_windows.go#L23 So if the name is relative path, Chdir make different point to the path. |
@alexbrainman, maybe not DeepEqual (internals are outside of scope), but |
Yes os.SameFile should work, and it does not. So we have a problem. I'll review CL 18181. Thank you, Brad. Alex |
You can reproduce by
Output is:
First and second line should be the same.
The text was updated successfully, but these errors were encountered: