-
Notifications
You must be signed in to change notification settings - Fork 7.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
Client hangs due to unexpected character parsing JSON (wrong type: string instead of int) #1086
Comments
I forgot to mention that removing I'll continue to investigate. |
The issue is in a project where I use Vendetta to manage deps and that is the version of gin I have there. In my |
Also works with current latest Seems the dep |
@murrekatt interesting, thanks for reporting, jsonite was not removed but made not default (through build flags, see https://github.com/gin-gonic/gin/blob/master/README.md#build-with-jsoniter), reopening and pinging @taowen |
it is a int field, and the input is a string. what is the expected behavior? |
@taowen that's not an issue, was my fault reading it. but I did found a worse issue, when @murrekatt says curl hangs, I find that cpu goes crazy 100% (1 core per request). I suspect it is some kind of loop in a goroutine. Any idea? (to test it, just run the example at top) |
jsoniter already returned a error which means the goroutine is no longer running jsoniter code. there is 0 goroutine started by jsoniter. Add some profiling to find out what is being executed when cpu goes crazy might be a easier path to resolution. |
@javierprovecho @taowen
I think the key point is maybe this case causes some infinite loop |
@cch123 pull request? |
@murrekatt @javierprovecho we have re-produced the bug func Test_invalid_number(t *testing.T) {
type Message struct {
Number int `json:"number"`
}
obj := Message{}
decoder := ConfigCompatibleWithStandardLibrary.NewDecoder(bytes.NewBufferString(`{"number":"5"}`))
err := decoder.Decode(&obj)
fmt.Println(err)
ConfigCompatibleWithStandardLibrary.Marshal(err.Error())
} There is a infinite loop in the Marshal when string is invalid utf8 |
json-iterator/go#153 should be fixed now |
closed via #1090 |
I ran into an issue when an int in a JSON message was accidentally passed in as a string. The caller e.g. curl hangs and the error is "unexpected character...".
I have a small gin server like so:
Build and run this and then make a call with curl:
Curl hangs and there is an error printed in the server console:
I've seen this now on both Linux and OSX.
Go version: go version go1.7.4 darwin/amd64
Gin hash:
65a6dd46a50bd435597b5bcababd1b2a811c9073
The text was updated successfully, but these errors were encountered: