flexdll
flexdll copied to clipboard
Fix parallel access to global symbol structures
The list of loaded units is defined globally in flexdll.c:
https://github.com/ocaml/flexdll/blob/cc0525e99e7109c8d3206085759185bd733ac49f/flexdll.c#L417
and is accessed in parallel both by flexdll_*dlopen and flexdll_dlsym without using a lock. Adding locks around flexdll_*dlopen is straightforward, but symbol lookup operates a most-recently-used queue on the global, and the performance impact either of removing that or, worse, of putting a lock around flexdll_dlsym is less clear.
In the meantime, reverting ocaml/ocaml#11607 provides an easy test-case for demonstrating the failure (the test usually fails within a few runs)