Bug 604691 - OCaml bindings are not thread safe
Summary: OCaml bindings are not thread safe
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs   
(Show other bugs)
Version: unspecified
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-16 14:01 UTC by Richard W.M. Jones
Modified: 2010-06-16 14:40 UTC (History)
2 users (show)

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


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

Description Richard W.M. Jones 2010-06-16 14:01:43 UTC
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 14:34:33 UTC
Patch posted upstream:
https://www.redhat.com/archives/libguestfs/2010-June/msg00099.html

Comment 2 Richard W.M. Jones 2010-06-16 14:40:43 UTC
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.