Bug 604691 - OCaml bindings are not thread safe
OCaml bindings are not thread safe
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
All Linux
low Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-16 10:01 EDT by Richard W.M. Jones
Modified: 2010-06-16 10:40 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-06-16 10:40:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Test case. (2.05 KB, text/plain)
2010-06-16 10:01 EDT, Richard W.M. Jones
no flags Details

  None (edit)
Description Richard W.M. Jones 2010-06-16 10:01:43 EDT
Created attachment 424468 [details]
Test case.

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);
  int r;

  caml_enter_blocking_section ();
  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):

1.3.20

How reproducible:

Test case attached which reproduces the problem most of the time.

Steps to Reproduce:
1. Run test case with LIBGUESTFS_DEBUG=1
2.
3.
  
Actual results:

Strings are sometimes corrupted.

Expected results:

Strings should not be corrupted.

Additional info:

Should take a copy of strings before calling enter_blocking_section.
Comment 1 Richard W.M. Jones 2010-06-16 10:34:33 EDT
Patch posted upstream:
https://www.redhat.com/archives/libguestfs/2010-June/msg00099.html
Comment 2 Richard W.M. Jones 2010-06-16 10:40:43 EDT
Fix seems obvious, simple and correct.  Pushed upstream.

Note You need to log in before you can comment on or make changes to this bug.