-
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: different os.File.WriteAt behavior with os.O_APPEND flag at osx and linux #30716
Comments
It's
|
@Gnouc Oh, I see. Thank you for answer! I'm closing this issue. |
@arturalbov maybe should re-open for adding documentation. cc @ianlancetaylor how do you think? |
Yes, I think we should fix this one way or another. Ideally we should change the os package to make the different systems work consistently, though I don't know how feasible that is. |
Change https://golang.org/cl/166578 mentions this issue: |
@Gnouc Please cut and paste text, rather than providing an image of a screen shot. Thanks. I want to make clear that I think that documenting this behavior is a last resort. It would be better to modify the os package to make it do the same thing on all platforms. |
Ah yes, just because it's not the code, and I have to ask my friend to run compiled program on his Windows, then he sent the result back to me.
Sure. I think about replace pwrite with |
If the problem only happens when o_append is passed to file.Open, what about not passing that flag down to syscall and manually positioning the fd at the end of the file prior to returning from Open?
… On 12 Mar 2019, at 14:22, Cuong Manh Le ***@***.***> wrote:
@ianlancetaylor
Please cut and paste text, rather than providing an image of a screen shot. Thanks.
Ah yes, just because it's not the code, and I have to ask my friend to run compiled program on his Windows, the he sent back the result to me.
I want to make clear that I think that documenting this behavior is a last resort. It would be better to modify the os package to make it do the same thing on all platforms.
Sure. I think about replace pwrite with lseek + write, not sure it's feasible.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@davecheney Seem we can’t, because O_APPEND takes effect on each write. We can check if file is open with O_APPEND, then do seek + write, but it’s not atomic anymore |
Ahh, right. Thanks for confirming. |
@ianlancetaylor Seems
How do you think? Implement it outside of |
Using What can we do on Windows? Another option might be to simply reject |
I don't see Windows offer anything equivalent to
does it break Go 1 compatibility promise? If not, I vote for it. |
Given that we made 12 point releases before anyone spotted this incompatibility the uses in the wild should be minimal, especially as anyone combining WriteAt with O_APPEND would corrupt their data, there is some evidence that there is little use of this combination in the wild. |
@alexbrainman do you have any idea? |
I don't. Not from the top of my head. Alex |
@ianlancetaylor Do you know any Windows experts to take a look at this issue? Otherwise, I think rejecting WriteAt in append mode is ok. I just update the CL to implement that behavior, please take a look. |
@ianlancetaylor, you still fine with that option? That's what the CL (https://go-review.googlesource.com/c/go/+/166578) does now. Seems fine to me. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OSX outputgo env
Linux outputWhat did you do?
Execution of this code on linux and osx gives different output
https://play.golang.org/p/aMQRT8-8os_V
What did you expect to see?
With
os.O_APPEND
flag I suppose both outputs should beWhat did you see instead?
Instead, on OSX output is:
and on Linux output is:
Btw, on playground output is the same as on OSX.
The text was updated successfully, but these errors were encountered: