[polyml] Add -5.5.2-fixes patch for bug fixes from upstream.
Jerry James
jjames at fedoraproject.org
Mon Jul 28 20:37:53 UTC 2014
commit 3baa9b6ce7ab6c8433fc42cada67aa4dea49de4d
Author: Jerry James <jamesjer at betterlinux.com>
Date: Mon Jul 28 14:36:58 2014 -0600
Add -5.5.2-fixes patch for bug fixes from upstream.
The following bugs are fixed:
- Check for negative sized arrays (trunk commit 1950)
- Fix segfault in FFI when malloc runs out of memory (trunk commit 1953)
polyml-5.5.2-fixes.patch | 146 ++++++++++++++++++++++++++++++++++++++++++++++
polyml.spec | 10 +++-
2 files changed, 155 insertions(+), 1 deletions(-)
---
diff --git a/polyml-5.5.2-fixes.patch b/polyml-5.5.2-fixes.patch
new file mode 100644
index 0000000..1be2844
--- /dev/null
+++ b/polyml-5.5.2-fixes.patch
@@ -0,0 +1,146 @@
+This patch currently contains the following subversion commits:
+- r1954
+Backport 1953 from trunk. Fix segfault in FFI when malloc runs out of memory.
+- r1952
+Backport commit 1950 (check for negative sized array) to fixes branch.
+- r1926
+Fix missing close quote in EXTRALDFLAGS.
+
+Index: polyml/basis/Array.sml
+===================================================================
+--- polyml/basis/Array.sml (revision 1924)
++++ polyml/basis/Array.sml (revision 1954)
+@@ -129,7 +129,7 @@
+
+ fun array(len, a) =
+ let
+- val () = if len >= maxLen then raise General.Size else ()
++ val () = if len < 0 orelse len >= maxLen then raise General.Size else ()
+ val vec = System_alloc(len+1, 0wx40, RunCall.unsafeCast a)
+ in
+ System_setw(vec, 0, RunCall.unsafeCast len);
+Index: polyml/libpolyml/foreign.cpp
+===================================================================
+--- polyml/libpolyml/foreign.cpp (revision 1924)
++++ polyml/libpolyml/foreign.cpp (revision 1954)
+@@ -4,7 +4,7 @@
+
+ Copyright (c) 2000-7
+ Cambridge University Technical Services Limited
+- Further development Copyright David C.J. Matthews 2008-2011.
++ Further development Copyright David C.J. Matthews 2008-2014.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+@@ -251,6 +251,10 @@
+
+ static Volatile *vols;
+ static PLock volLock; // Mutex to protect vols.
++// TODO: There is a theoretical risk of deadlock if any ML allocation is made while this
++// lock is held. An allocation can result in a GC which requires all threads to release
++// ML memory but another thread could block waiting for the mutex.
++// N.B. raising an exception involves an allocation.
+
+ #define FIRST_VOL 0
+
+@@ -268,24 +272,8 @@
+ static unsigned callBackEntries = 0;
+ static PLock callbackTableLock; // Mutex to protect table.
+
+-
+ /**********************************************************************
+ *
+- * Malloc / Free Wrappers
+- *
+- **********************************************************************/
+-
+-static POLYUNSIGNED malloc_count = 0;
+-#if 0
+-#define Vmalloc(where,size) {where = malloc(size); printf("malloc: %p,%d\n",where,size); fflush(stdout); malloc_count++;}
+-#else
+-#define Vmalloc(where,size) {where = malloc(size); malloc_count++;}
+-#endif
+-#define Vfree(p) { free(p); malloc_count--;}
+-
+-
+-/**********************************************************************
+- *
+ * Volatile Allocation
+ *
+ **********************************************************************/
+@@ -349,8 +337,12 @@
+ PLocker plocker(&volLock);
+ Handle res = vol_alloc(taskData);
+ trace(("size= %" POLYUFMT "\n",size));
+- Vmalloc( C_POINTER(UNVOLHANDLE(res)), size );
++ void *p = malloc(size);
++ if (p == 0)
++ RAISE_EXN("Insufficient memory");
++ C_POINTER(UNVOLHANDLE(res)) = p;
+ OWN_C_SPACE(UNVOLHANDLE(res)) = true;
++
+ return res;
+ }
+
+@@ -685,7 +677,7 @@
+ {
+ // Can now free this.
+ trace(("Freeing malloc space of <%" POLYUFMT ">\n",from));
+- Vfree(vols[from].C_pointer);
++ free(vols[from].C_pointer);
+ vols[from].C_pointer = 0;
+ vols[from].Own_C_space = false;
+ }
+@@ -702,7 +694,6 @@
+ }
+ }
+ next_vol = to;
+- info(("unfreed mallocs=<%" POLYUFMT "> next_vol=<%" POLYUFMT ">\n", malloc_count, next_vol));
+
+ /* Callback table. Added DCJM 12/4/04. We always process these as strong references.
+ For the time being at any rate we treat these as permanent entries so that once a
+@@ -910,8 +901,9 @@
+ RAISE_EXN("libffi error: ffi_prep_cif failed");
+
+ // malloc memory for the result
+- void *result;
+- Vmalloc(result, result_type->size);
++ void *result = malloc(result_type->size);
++ if (result == 0)
++ RAISE_EXN("Insufficient memory to allocate space for result");
+
+ processes->ThreadReleaseMLMemory(taskData);
+ ffi_call(&cif, sym, result, arg_values);
+@@ -1580,6 +1572,9 @@
+
+ unsigned num_args = length_list(argTypeList->Word());
+ ffi_type **arg_types = (ffi_type**)malloc(num_args * sizeof(ffi_type*));
++ if (arg_types == 0)
++ RAISE_EXN("Insufficient memory to allocate space for arguments");
++
+ PolyWord p = argTypeList->Word();
+ for (POLYUNSIGNED i=0; i<num_args; i++,p=Tail(p))
+ arg_types[i] = ctypeToFfiType(taskData, Head(p));
+@@ -1587,6 +1582,9 @@
+
+ // The cif needs to be on the heap so that it is available in the callback.
+ ffi_cif *cif = (ffi_cif *)malloc(sizeof(ffi_cif));
++ if (cif == 0)
++ RAISE_EXN("Insufficient memory to allocate space for cif");
++
+ if (ffi_prep_cif(cif, abi, num_args, result_type, arg_types) != FFI_OK)
+ RAISE_EXN("libffi error: ffi_prep_cif failed");
+
+Index: polyml/polyc.in
+===================================================================
+--- polyml/polyc.in (revision 1924)
++++ polyml/polyc.in (revision 1954)
+@@ -19,7 +19,7 @@
+ @NATIVE_WINDOWS_FALSE at SUFFIX="o"
+
+ # Extra options for Mac OS X
+- at EXPMACHO_TRUE@EXTRALDFLAGS="-Wl,-no_pie
++ at EXPMACHO_TRUE@EXTRALDFLAGS="-Wl,-no_pie"
+
+ TMPSRCFILE=/tmp/polysrc.$$
+ TMPOBJFILE=/tmp/polyobj.$$.$SUFFIX
diff --git a/polyml.spec b/polyml.spec
index aacd1b8..6e67724 100644
--- a/polyml.spec
+++ b/polyml.spec
@@ -1,6 +1,6 @@
Name: polyml
Version: 5.5.2
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Poly/ML compiler and runtime system
Group: Development/Languages
@@ -9,6 +9,8 @@ URL: http://www.polyml.org
Source0: http://downloads.sourceforge.net/%{name}/%{name}.%{version}.tar.gz
# 2013-09-17 snapshot of http://www.polyml.org/docs/.
Source1: polyml-docs.tar.xz
+# Bug fixes from upstream's polyml-5.5.2-fixes subversion branch.
+Patch0: %{name}-5.5.2-fixes.patch
# The standard solution to kill the libtool-induced RPATH is to edit the
# libtool script to kill it. However, that causes problems for us as we need
@@ -54,6 +56,7 @@ Runtime libraries for Poly/ML.
%prep
%setup -q -n polyml.%{version}
%setup -q -T -D -a 1 -n polyml.%{version}
+%patch0 -p1
%build
# Some hand-coded assembler is included. Because it does not contain an
@@ -99,6 +102,11 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
%{_libdir}/libpolyml.so.*
%changelog
+* Mon Jul 28 2014 Jerry James <loganjerry at gmail.com> - 5.5.2-3
+- Add -5.5.2-fixes patch to fix the following:
+ o Check for negative sized arrays (trunk commit 1950)
+ o Fix segfault in FFI when malloc runs out of memory (trunk commit 1953)
+
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 5.5.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
More information about the scm-commits
mailing list