Red Hat Bugzilla – Bug 604691
OCaml bindings are not thread safe
Last modified: 2010-06-16 10:40:43 EDT
Created attachment 424468 [details]
Description of problem:
OCaml bindings take pointers to strings on the OCaml heap, and
then allow other threads to run. For example:
const char *filename = String_val (filenamev);
r = guestfs_add_drive_ro (g, filename);
If other threads run (after caml_enter_blocking_section and while
waiting for the command to complete) then the GC could move or
reclaim the string pointed to by 'filename'.
Version-Release number of selected component (if applicable):
Test case attached which reproduces the problem most of the time.
Steps to Reproduce:
1. Run test case with LIBGUESTFS_DEBUG=1
Strings are sometimes corrupted.
Strings should not be corrupted.
Should take a copy of strings before calling enter_blocking_section.
Patch posted upstream:
Fix seems obvious, simple and correct. Pushed upstream.