Package lmdb.1.1.2 - #30198
Conversation
301c19e to
94d9b48
Compare
|
Is this deliberately a draft PR @madroach? |
|
Yes. This is not yet ready. |
0061e2c to
bc08b93
Compare
|
Tests on MacOS still fail randomly. No matter whether we use the system lmdb backend version 0.9.35 or the included version 1.0.0. To me this seems to be a bug in the backend or even MacOS. |
disabled system lmdb to see whether shipped lmdb 1.0.0 would fix test failures on MacOS. This did not fix the test failures. Therefore re-enable depexts on system lmdb.
|
Since I don't own any Apple silicone I got an account on macincloud.com. There the tests all pass reliably on Apple M2 macOS Tahoe 26.2. The CI MacOS tests run on amd64. I have no idea about how to look further into this. |
|
I've rerun this and some more pass while others still fail. I then looked at the stubs code: https://github.com/Drup/ocaml-lmdb/blob/master/src/lmdb_stubs.c I recommend https://ocaml.org/manual/5.5/intfc.html#s:c-gc-harmony
I see several functions in https://github.com/Drup/ocaml-lmdb/blob/master/src/lmdb_stubs.c not respecting that. |
|
@jmid Thanks for trying again and having a look at the stubs. I'm pretty sure I'm handling the GC and allocating stuff correctly. The manual says this:
In most stubs I don't need to register the
Do you still see any unsafe omitance of root registrations? |
|
Hm, I've now spent a good chunk of time scratching my head over this stubs code. Looking at: CAMLprim value mdbs_init(value unit)
{
CAMLparam0();
CAMLlocal4(version, string, array, pair);
int major, minor, patch;
unsigned i;
exn_exists = caml_named_value("LmdbExists");
exn_map_full = caml_named_value("LmdbMapFull");
exn_error = caml_named_value("LmdbError");
[...]where the latter looks up values and stores them in global variables. The manual page says:
I'm wondering if those globally cached pointers can't be invalidated by an OCaml heap allocation happening before they are read? This callback function also strikes me as dangerous: int mdbs_msg_func(const char *msg, void *callback)
{
int ret;
caml_acquire_runtime_system();
ret = Int_val(caml_callback(
*(value *)callback,
caml_copy_string(msg)));
caml_release_runtime_system();
return ret;
}
|
|
@jmid Thanks again for looking into this code ! About
That's what I do in the stubs, too. I store the constant The If you want to continue this conversation, please open an issue at https://github.com/Drup/ocaml-lmdb/issues or just send me an email. |
myocamlbuild.ml: finding lmdb backend, fallback to shipped backendbigstringaf