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
GC issue with string view #530
Comments
Thanks. If this is the case, can it ever be safe to use a string view to pass data to a function? I can see no way to enforce the lifetime of the internal array. |
This is the test code calling the above. The
Running the
Note that the OCaml version is producing the same values each time, and the C bound version differs in the 2 runs. Using the CArray version no errors are printed. |
FYI; the code being bound is here https://sourceforge.net/p/cmph/git/ci/master/tree/src/jenkins_hash.c#l283 (and really implemented here) https://sourceforge.net/p/cmph/git/ci/master/tree/src/jenkins_hash.c#l102 |
Thanks for the detailed report. I can reproduce the bug here, and I think I've found the root cause: intermediate values generated by views, including |
I have written the following wrapper for a hashing function from the cmph library.
It uses a string coercion to pass a pointer to a char buffer. Running 10K times leads to occasional incorrect values being calculated.
Different runs produce values, though always on the same iteration. Adding a
Gc.full_major
after everyn
th loop will change which iteration it occurs on.The following, which allocates a CArray explicitly, seems to be fine.
Any thoughts on what might be happening?
The text was updated successfully, but these errors were encountered: