alan icon indicating copy to clipboard operation
alan copied to clipboard

Currently undocumented `@std/datastore` has type unsoundness issue

Open dfellis opened this issue 4 years ago • 0 comments

@std/datastore, our system for shared mutable state to persist in the language, is accidentally able to unsafe cast any type to any other type through its current set and get functions.

While being able to directly manipulate the bytes of a float by casting to an int can in rare circumstances be the right choice, it's very bad to accidentally cast an int to an array of arrays and then cause the AVM to crash accessing invalid memory. So fixing up the type soundness of @std/datastore is paramount, and perhaps adding asInt64/asFloat64 functions to allow the manipulation of integers as floats and vice versa for those esoteric situations.

dfellis avatar Feb 15 '21 20:02 dfellis