-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
encoding/gob: gob.(*Decoder).Decode failed #69131
Comments
Can you show us a small, complete, standalone program that demonstrates the problem? Thanks. |
I’m very sorry, but it's difficult to reproduce it as a small, complete, standalone program, so I can't provide a demo. Stack: My thoughts: What I did: |
Change https://go.dev/cl/609759 mentions this issue: |
There are similar usages because there is nothing wrong with that usage. A call to The encoding/gob package does not set any timeouts, and it does not expect to operate over a connection that can have timeouts and then recover. |
I think we can close as working as intended for encoding/gob |
I'll note that you could write a custom implementation of |
I understand that io.ReadFull works fine on its own; if an error occurs, it returns the data read up to that point. When there is an I/O timeout, it might be better to handle the partial data in readMessage rather than just using saferio.ReadData.
In fact, I tried using a custom io.Reader and set it to ignore timeouts, but the problem still persists. What’s puzzling is that I found the first syscall.Read encountering an syscall.EAGAIN(I/O timeout) occurs within the same second. |
Sorry for the late reply. |
It's entirely normal for |
Go version
go version 1.21.1 or newer
Output of
go env
in your module/workspace:What did you do?
...
conn, _ := net.Dial("tcp", addr)
enc := gob.NewEncoder(conn)
dec := gob.NewDecoder(bufio.NewReader(conn))
...
Simply put, Encode serializes and Decode deserializes data for network transmission.
What did you see happen?
Data packets can vary in size. When Decode fails, the first error that occurs is 'read tcp 10.35.146.11:54754->10.35.146.7:9527: i/o timeout'.
After this, Decode may continuously produce a series of errors such as 'gob: duplicate type received' and 'gob: unknown type id or corrupted data'.
What did you expect to see?
I've tried to fix the bug and will attempt to submit a pull request.
The text was updated successfully, but these errors were encountered: