-
Notifications
You must be signed in to change notification settings - Fork 18k
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/json: detect cyclic maps and slices #40756
Conversation
This PR (HEAD: 920ce83) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
The documentation says: JSON cannot represent cyclic data structures and Marshal does not handle them. Passing cyclic structures to Marshal will result in an error. However, passing cyclic maps or slices still results in an infinite recursion. Cycle detection is now added into mapEncoder and sliceEncoder. name old time/op new time/op delta CodeEncoder-16 933µs ± 0% 1324µs ± 0% ~ (p=1.000 n=1+1) CodeMarshal-16 940µs ± 0% 1436µs ± 0% ~ (p=1.000 n=1+1) name old speed new speed delta CodeEncoder-16 2.08GB/s ± 0% 1.47GB/s ± 0% ~ (p=1.000 n=1+1) CodeMarshal-16 2.06GB/s ± 0% 1.35GB/s ± 0% ~ (p=1.000 n=1+1) name old alloc/op new alloc/op delta CodeEncoder-16 7.00B ± 0% 94933.00B ± 0% ~ (p=1.000 n=1+1) CodeMarshal-16 1.98MB ± 0% 2.04MB ± 0% ~ (p=1.000 n=1+1) name old allocs/op new allocs/op delta CodeEncoder-16 0.00 11816.00 ± 0% ~ (p=1.000 n=1+1) CodeMarshal-16 1.00 ± 0% 11816.00 ± 0% ~ (p=1.000 n=1+1) Fixes #40745.
This PR (HEAD: 5ea40da) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: b69943d) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
Message from Jiahao Lu: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Emmanuel Odeke: Patch Set 4: Run-TryBot+1 (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 4: TryBots beginning. Status page: https://farmer.golang.org/try?commit=f242f725 Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 4: Build is still in progress... Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 4: TryBot-Result-1 1 of 20 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
This PR (HEAD: 409d916) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: d80d86b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
Message from Jiahao Lu: Patch Set 7: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Jiahao Lu: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Jiahao Lu: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Emmanuel Odeke: Patch Set 7: Run-TryBot+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 7: TryBots beginning. Status page: https://farmer.golang.org/try?commit=752a5eed Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 7: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Emmanuel Odeke: Patch Set 8: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Jiahao Lu: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 8: TryBots beginning. Status page: https://farmer.golang.org/try?commit=5c8a51d7 Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 8: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Daniel Martí: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Jiahao Lu: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Daniel Martí: Patch Set 8: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
This PR (HEAD: 6f87494) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/248358 to see it. Tip: You can toggle comments from me using the |
Message from Jiahao Lu: Patch Set 9: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Daniel Martí: Patch Set 9: Run-TryBot+1 Code-Review+2 Trust+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 9: TryBots beginning. Status page: https://farmer.golang.org/try?commit=a5bb170d Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Gobot Gobot: Patch Set 9: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Message from Bryan C. Mills: Patch Set 9: Trust+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/248358. |
Now reports an error if cyclic maps and slices are to be encoded instead of an infinite recursion. This case wasn't handled in CL 187920. Fixes #40745. Change-Id: Ia34b014ecbb71fd2663bb065ba5355a307dbcc15 GitHub-Last-Rev: 6f87494 GitHub-Pull-Request: #40756 Reviewed-on: https://go-review.googlesource.com/c/go/+/248358 Reviewed-by: Daniel Martí <[email protected]> Trust: Daniel Martí <[email protected]> Trust: Bryan C. Mills <[email protected]> Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Go Bot <[email protected]>
This PR is being closed because golang.org/cl/248358 has been merged. |
Now reports an error if cyclic maps and slices are to be encoded instead of an infinite recursion. This case wasn't handled in CL 187920. Fixes #40745. Change-Id: Ia34b014ecbb71fd2663bb065ba5355a307dbcc15 GitHub-Last-Rev: 6f874944f4065b5237babbb0fdce14c1c74a3c97 GitHub-Pull-Request: golang/go#40756 Reviewed-on: https://go-review.googlesource.com/c/go/+/248358 Reviewed-by: Daniel Martí <[email protected]> Trust: Daniel Martí <[email protected]> Trust: Bryan C. Mills <[email protected]> Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Go Bot <[email protected]>
Now reports an error if cyclic maps and slices are to be encoded instead of an infinite recursion. This case wasn't handled in CL 187920. Fixes #40745. Change-Id: Ia34b014ecbb71fd2663bb065ba5355a307dbcc15 GitHub-Last-Rev: 6f874944f4065b5237babbb0fdce14c1c74a3c97 GitHub-Pull-Request: golang/go#40756 Reviewed-on: https://go-review.googlesource.com/c/go/+/248358 Reviewed-by: Daniel Martí <[email protected]> Trust: Daniel Martí <[email protected]> Trust: Bryan C. Mills <[email protected]> Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Go Bot <[email protected]>
Now reports an error if cyclic maps and slices are to be encoded instead of an infinite recursion. This case wasn't handled in CL 187920. Fixes #40745. Change-Id: Ia34b014ecbb71fd2663bb065ba5355a307dbcc15 GitHub-Last-Rev: 6f874944f4065b5237babbb0fdce14c1c74a3c97 GitHub-Pull-Request: golang/go#40756 Reviewed-on: https://go-review.googlesource.com/c/go/+/248358 Reviewed-by: Daniel Martí <[email protected]> Trust: Daniel Martí <[email protected]> Trust: Bryan C. Mills <[email protected]> Run-TryBot: Daniel Martí <[email protected]> TryBot-Result: Go Bot <[email protected]>
Now reports an error if cyclic maps and slices are to be encoded
instead of an infinite recursion. This case wasn't handled in CL 187920.
Fixes #40745.