flexdll
flexdll copied to clipboard
Fix parallel access crashes and misbehavior
Parallel usage is memory unsafe (read: may crash) as documented in #120, ocaml/ocaml#11607, and ocaml/ocaml#13046.
This PR goes for the simplest possible fix: adding a single global lock by dusting off the first commit of https://github.com/dra27/flexdll/tree/sledgehammer and suitable rebasing, renaming, and error handling. Author credit thus goes to @dra27 - any errors are mine.
For the error handling, I've tried to make it fit with @shym's TLS-based error handling from #112. I'm unsure how to test these error code paths though without explicitly mocking with the source code to create an invalid lock handle.
With the fix
- the ocaml/ocaml testsuite passes incl. the disabled
tests/lib-dynlink-domainstest from ocaml/ocaml#11607 - the reproducer from ocaml/ocaml#13046 also passes
- the
Dynlinkstress test frommulticoretestspasses
(these have been tested under MinGW in a Cygwin-shell)