Closed Niols closed 3 years ago
Also, an other note: the const
keyword is added in two kind of places:
On char*
values coming from a String_val
call. This is because OCaml strings are supposed to be immutable and therefore correspond to const char*
and not just char*
.
On value*
values corresponding to an OCaml closure.
I think we want closures to be always const value*
and not value*
; I do not see any use of an API that would let C change pointers to OCaml functions. For the strings, it is not clear. We might consider that we do not actually use those strings and that, therefore, C should be free to change them if required. In this case, I would advise to remove the const
keywords but to use the Bytes_val
macros instead.
yes, this is fixed for me on the branch niols/conservative-cstub. Thanks -Ralf.
We make the C stubs more conservative by adding the
const
keyword wherever necessary. Otherwise, someone building against the C API could change values or pointers used by other functions of the API (or subsequent calls to the same functions).fix #129
We should probably wait for the CI to be fixed before merging this, and also for #130 to add other tests that have to do with the C API.
@treinen Would you confirm that you do not encounter #129 anymore on this branch?