-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: []byte(str) occasionally causes a panic #70918
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
Go 1.9.2 is more than 7 years old and definitely not supported anymore. :) Does this reproduce on the latest release of Go (1.23.4)? |
You've got a bad string input to |
This is an error log generated in the production environment after running the binary compiled through 1.9.2. |
Thank you for your attention. |
I'm going to close this issue, as I don't think there's anything we can do. We'd need to know where that bad string came from. |
Go version
go1.9.2
Output of
go env
in your module/workspace:What did you do?
In the program, using the mgo package to convert a struct to BSON format data is causing a panic.
This issue has occurred for the first time since the program started running in the production environment in 2018.
After analyzing the complete panic log, we found that the panic occurred at Line 480.
github.com/project/vendor/github.com/project/mgo/bson.(*encoder).addCStr(0xc43098b0e8, 0x0, 0x3) /opt/gohome/src/github.com/project/vendor/github.com/project/mgo/bson/encode.go:480 +0x43
The log clearly indicates that
(e *encoder)
is not a nil pointer, so the issue is likely caused by[]byte(v)...
.We were shocked by the analysis conclusion, so we tried to simulate it locally 100 million times and did not encounter any panic.
We realized that this may be a system-level or memory-level issue, so we would like to seek official help.
What did you see happen?
What did you expect to see?
[]byte(v)...: Convert string v to a byte array and unpack the array into a list of bytes.
It is very confusing for us that this operation resulted in a panic, as we could not find any relevant information in the repository's issue tracker, release notes, or fix records.
The text was updated successfully, but these errors were encountered: