You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems OK when the buffer is Go-allocated since the GC will take care of it (regardless of Release/Retain). But when the buffer is C-allocated (e.g. C Data Interface, mallocator), if the string outlives the array, we have a dangling pointer!
I believe we should copy the string (and frankly, get rid of the unsafe here) to be safe (which also has the side effect that getting a single value out of an array will no longer keep the entire backing array alive). If the extra garbage is an issue, we should consider some sort of string view type.
Component(s)
Go
The text was updated successfully, but these errors were encountered:
Describe the bug, including details regarding any error messages, version, and platform.
String.Value slices a backing string:
Which points directly into the buffer data:
This seems OK when the buffer is Go-allocated since the GC will take care of it (regardless of Release/Retain). But when the buffer is C-allocated (e.g. C Data Interface, mallocator), if the string outlives the array, we have a dangling pointer!
I believe we should copy the string (and frankly, get rid of the unsafe here) to be safe (which also has the side effect that getting a single value out of an array will no longer keep the entire backing array alive). If the extra garbage is an issue, we should consider some sort of string view type.
Component(s)
Go
The text was updated successfully, but these errors were encountered: