go-json icon indicating copy to clipboard operation
go-json copied to clipboard

Question regarding NoEscape reliability

Open opalzenith opened this issue 4 years ago • 2 comments

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.

opalzenith avatar Jul 29 '21 05:07 opalzenith

This is a good question, @goccy do you have a link to the bug in question on the Go issue tracker?

Splizard avatar Dec 16 '21 00:12 Splizard

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

NyaaaWhatsUpDoc avatar Mar 05 '22 08:03 NyaaaWhatsUpDoc