go-json
go-json copied to clipboard
Question regarding NoEscape reliability
Initially this feature was the default behavior of go-json. But after careful testing, I found that I passed a large value to json.Marshal() and if the argument could not be assigned to the stack, it could not be properly escaped to the heap (a bug in the Go compiler).
Therefore, this feature will be provided as an optional until this issue is resolved.
Do you know the current status of this compiler bug as of Go 1.17, or what data sizes are likely to be affected by the bug? In general, how reliable do you think MarshalNoEscape and UnmarshalNoEscape should be for JSON string or Go value sizes that are, say, under 8 KB? Or is it unpredictable and super variable depending on the system/application?
Thanks.
This is a good question, @goccy do you have a link to the bug in question on the Go issue tracker?
I mean, is this a compiler bug? By using your noescape hack you're explicitly telling the compiler that it never escapes and not to worry about it. This sounds like behaviour as expected