[libguestfs/f15] Add upstream patch to fix segfault in OCaml bindings (RHBZ#725824).

Richard W.M. Jones rjones at fedoraproject.org
Tue Jul 26 18:19:29 UTC 2011


commit 56eb087bc680d810c7cbfdc81da171633749e12e
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Jul 26 19:14:06 2011 +0100

    Add upstream patch to fix segfault in OCaml bindings (RHBZ#725824).

 0001-ocaml-Fix-locking-in-event-callbacks.patch |   58 +++++++++++++++++++++++
 libguestfs.spec                                 |    9 +++-
 2 files changed, 66 insertions(+), 1 deletions(-)
---
diff --git a/0001-ocaml-Fix-locking-in-event-callbacks.patch b/0001-ocaml-Fix-locking-in-event-callbacks.patch
new file mode 100644
index 0000000..2ef7fc2
--- /dev/null
+++ b/0001-ocaml-Fix-locking-in-event-callbacks.patch
@@ -0,0 +1,58 @@
+diff -ur libguestfs-1.10.5.orig/ocaml/guestfs_c.c libguestfs-1.10.5/ocaml/guestfs_c.c
+--- libguestfs-1.10.5.orig/ocaml/guestfs_c.c	2011-03-15 12:16:50.000000000 +0000
++++ libguestfs-1.10.5/ocaml/guestfs_c.c	2011-07-26 19:17:12.318125243 +0100
+@@ -325,13 +325,13 @@
+ }
+ 
+ static void
+-event_callback_wrapper (guestfs_h *g,
+-                        void *data,
+-                        uint64_t event,
+-                        int event_handle,
+-                        int flags,
+-                        const char *buf, size_t buf_len,
+-                        const uint64_t *array, size_t array_len)
++event_callback_wrapper_locked (guestfs_h *g,
++                               void *data,
++                               uint64_t event,
++                               int event_handle,
++                               int flags,
++                               const char *buf, size_t buf_len,
++                               const uint64_t *array, size_t array_len)
+ {
+   CAMLparam0 ();
+   CAMLlocal5 (gv, evv, ehv, bufv, arrayv);
+@@ -358,9 +358,7 @@
+ 
+   value args[5] = { gv, evv, ehv, bufv, arrayv };
+ 
+-  caml_leave_blocking_section ();
+   rv = caml_callbackN_exn (*(value*)data, 5, args);
+-  caml_enter_blocking_section ();
+ 
+   /* Callbacks shouldn't throw exceptions.  There's not much we can do
+    * except to print it.
+@@ -372,3 +370,23 @@
+ 
+   CAMLreturn0;
+ }
++
++static void
++event_callback_wrapper (guestfs_h *g,
++                        void *data,
++                        uint64_t event,
++                        int event_handle,
++                        int flags,
++                        const char *buf, size_t buf_len,
++                        const uint64_t *array, size_t array_len)
++{
++  /* Ensure we are holding the GC lock before any GC operations are
++   * possible. (RHBZ#725824)
++   */
++  caml_leave_blocking_section ();
++
++  event_callback_wrapper_locked (g, data, event, event_handle, flags,
++                                 buf, buf_len, array, array_len);
++
++  caml_enter_blocking_section ();
++}
diff --git a/libguestfs.spec b/libguestfs.spec
index 0a06a27..0ea1c06 100644
--- a/libguestfs.spec
+++ b/libguestfs.spec
@@ -30,7 +30,7 @@ Summary:       Access and modify virtual machine disk images
 Name:          libguestfs
 Epoch:         1
 Version:       1.10.5
-Release:       1%{?dist}
+Release:       2%{?dist}
 License:       LGPLv2+
 Group:         Development/Libraries
 URL:           http://libguestfs.org/
@@ -40,6 +40,9 @@ BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root
 # Disable FUSE tests, not supported in Koji at the moment.
 Patch0:        libguestfs-1.7.13-no-fuse-test.patch
 
+# Upstream patch to fix segfault in OCaml bindings.
+Patch1:        0001-ocaml-Fix-locking-in-event-callbacks.patch
+
 # Basic build requirements:
 BuildRequires: /usr/bin/pod2man
 BuildRequires: /usr/bin/pod2text
@@ -436,6 +439,7 @@ php-%{name} contains PHP bindings for %{name}.
 %setup -q
 
 %patch0 -p1
+%patch1 -p1
 
 mkdir -p daemon/m4
 
@@ -774,6 +778,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Thu Jul 26 2011 Richard W.M. Jones <rjones at redhat.com> - 1:1.10.5-2
+- Add upstream patch to fix segfault in OCaml bindings (RHBZ#725824).
+
 * Wed Jul 13 2011 Richard W.M. Jones <rjones at redhat.com> - 1:1.10.5-1
 - New upstream stable branch 1.10.5.
 - Fixes: RHBZ#661280 RHBZ#602997 RHBZ#685009.


More information about the scm-commits mailing list