-
Notifications
You must be signed in to change notification settings - Fork 30
fix usage of Bytes.unsafe_of_string #20
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
Conversation
Don't reuse strings after they get unsafely converted to bytes for mutation. Intead, explicitly refer to the mutated bytes
I agree that the use of |
@gasche - the function is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, and I checked that the remaining uses of unsafe_
functions are sound (the remaining ones are all Bytes.unsafe_to_string
where the constructed bytes
value truly is then not subsequently mutated)
@hhugo - there appear to remain some issues with |
Well We can remain compatible with other users by providing both variants in the API. It's fairly easy (and slightly less efficient, but we don't really care about that) to implement the nice |
any news / progress ? |
I decided to go ahead and merge this patch. |
Could we have a minor release that include that change ? |
The last release of So could we tag the release in this repo but please not release it to opam - I'd like to liaise with them and do a test release of it first to see if we can isolate what went wrong. |
@dra27, has the issue with new release of num been resolved ? Can we can have a new release of num now ? |
Any update on the new release ? |
I loosely had it in mind to allow 4.11 out of the door first |
4.11 is out. Can we have a release now ? |
I've opened #21 to track the pending new release |
Don't reuse strings after they get (unsafely) converted to bytes for mutation. Instead, explicitly refer to the mutated bytes.
Also remove instances of
Bytes.unsafe_of_string
as theses usages are incorrect based on the documentation (see https://github.com/ocaml/ocaml/blob/trunk/stdlib/bytes.mli#L408)This issue was discovered while working on ocsigen/js_of_ocaml#923 which changes the representation of ocaml strings to be different from the representation of bytes.