-
Notifications
You must be signed in to change notification settings - Fork 18k
go/internal/gccgoimporter: File.ReadAt moves underlying seek position on Plan9? #11265
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
Comments
I don't think we need to repeat the io.ReaderAt docs on every implementation thereof. This is just a Plan 9 bug. |
Work-around issue #11265 and re-enable tests for Plan9. Change-Id: I3aabb674a149b8eb936f948dd4cda5fd81454646 Reviewed-on: https://go-review.googlesource.com/11194 Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
It appears that https://go-review.googlesource.com/11194 makes the Plan9 test pass, confirming the hypothesis above. |
Also revert https://go-review.googlesource.com/11210 |
It's fine to revert once the bug is fixed. This is not critical and the On Wed, Jun 17, 2015 at 5:34 PM, Brad Fitzpatrick notifications@github.com
|
Thanks for investigating this issue. In my understanding, the Plan 9 read documentation says that:
Is equivalent to:
So, it does indeed change the seek offset, which is not the behavior expected by Go. I think the solution is to call f.seek(0, SEEK_SET) just after syscall.Pread in Go's implementation of pread on Plan 9. What do you think? |
That's not how I read those docs. Look at the last sentence:
So it seems like the normal |
@0intro, even if it does atomically do the seek + read but leaves the seek offset modified for other threads, that still violates Go's semantics. In Go, one goroutine must be allowed to use an io.Reader+io.ReaderAt as a Reader while the other uses the same value as an io.ReaderAt, and neither one of them is allowed to interfere with the other goroutine. Where is the Plan 9 source for the implementation of pread? |
Here: https://github.com/0intro/plan9/blob/bd0c9332d5/sys/src/9/port/sysfile.c#L701 |
I'm working on this in https://go-review.googlesource.com/11280 However, I now think it's a kernel bug. Awaiting feedback on 9fans. |
CL https://golang.org/cl/11280 mentions this issue. |
This is a Plan 9 kernel bug. |
https://go-review.googlesource.com/#/c/11152/ fails on Plan 9 without line 7 in https://go-review.googlesource.com/#/c/11152/7/src/go/internal/gccgoimporter/importer_test.go (and the corresponding line 7 in https://go-review.googlesource.com/#/c/11152/7/src/go/internal/gccgoimporter/gccgoinstallation_test.go).
The change was submitted with the tests disabled for Plan 9. When actually running the tests on Plan 9 (i.e., without the build tag), the failure is:
( https://storage.googleapis.com/go-build-log/e6448c25/plan9-386_c70f45b0.log )
Analysis:
In this specific test, the go/internal/gccgoimporter/testdata/*.gox files are read. In a first step, openExportFile (importer.go:74ff) reads the first 4 "magic" bytes using File.ReadAt (line 87). They are "v1;\n" (see e.g. testdata/pointer.gox). In a 2nd step, the closure returned by GetImporter (importer.go:142ff) reads the file's magic bytes again, this time via io.ReadSeeker.Read. It appears that the next 4 bytes "pack" are read this time, leading to the above error.
On non-Plan9 systems, this error doesn't appear. It seems that the Plan9 File.ReadAt moves the seek position, while other OSes don't.
From the documentation:
"If ReadAt is reading from an input source with a seek offset, ReadAt should not affect nor be affected by the underlying seek offset."
It would appear the File.ReadAt should follow this specification as well (and perhaps it should be documented).
The text was updated successfully, but these errors were encountered: