flexdll icon indicating copy to clipboard operation
flexdll copied to clipboard

Fix parallel access crashes and misbehavior

Open jmid opened this issue 1 year ago • 0 comments

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-domains test from ocaml/ocaml#11607
  • the reproducer from ocaml/ocaml#13046 also passes
  • the Dynlink stress test from multicoretests passes

(these have been tested under MinGW in a Cygwin-shell)

jmid avatar Apr 16 '24 14:04 jmid