Use ffi_closure_alloc to avoid segmentation fault by libffi on aarch64.
Resolves: rhbz#1727832
This commit is contained in:
parent
e3b4b9752e
commit
c29a112f31
|
@ -0,0 +1,61 @@
|
|||
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
|
||||
index 1a80b2b..b997e23 100644
|
||||
--- a/ext/fiddle/closure.c
|
||||
+++ b/ext/fiddle/closure.c
|
||||
@@ -13,25 +13,11 @@ typedef struct {
|
||||
ffi_type **argv;
|
||||
} fiddle_closure;
|
||||
|
||||
-#if defined(USE_FFI_CLOSURE_ALLOC)
|
||||
-#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__)
|
||||
-# define USE_FFI_CLOSURE_ALLOC 0
|
||||
-#elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \
|
||||
- (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64))
|
||||
-# define USE_FFI_CLOSURE_ALLOC 0
|
||||
-#else
|
||||
-# define USE_FFI_CLOSURE_ALLOC 1
|
||||
-#endif
|
||||
-
|
||||
static void
|
||||
dealloc(void * ptr)
|
||||
{
|
||||
fiddle_closure * cls = (fiddle_closure *)ptr;
|
||||
-#if USE_FFI_CLOSURE_ALLOC
|
||||
ffi_closure_free(cls->pcl);
|
||||
-#else
|
||||
- munmap(cls->pcl, sizeof(*cls->pcl));
|
||||
-#endif
|
||||
if (cls->argv) xfree(cls->argv);
|
||||
xfree(cls);
|
||||
}
|
||||
@@ -205,12 +191,7 @@ allocate(VALUE klass)
|
||||
VALUE i = TypedData_Make_Struct(klass, fiddle_closure,
|
||||
&closure_data_type, closure);
|
||||
|
||||
-#if USE_FFI_CLOSURE_ALLOC
|
||||
closure->pcl = ffi_closure_alloc(sizeof(ffi_closure), &closure->code);
|
||||
-#else
|
||||
- closure->pcl = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
|
||||
- MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
-#endif
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -257,17 +238,8 @@ initialize(int rbargc, VALUE argv[], VALUE self)
|
||||
if (FFI_OK != result)
|
||||
rb_raise(rb_eRuntimeError, "error prepping CIF %d", result);
|
||||
|
||||
-#if USE_FFI_CLOSURE_ALLOC
|
||||
result = ffi_prep_closure_loc(pcl, cif, callback,
|
||||
(void *)self, cl->code);
|
||||
-#else
|
||||
- result = ffi_prep_closure(pcl, cif, callback, (void *)self);
|
||||
- cl->code = (void *)pcl;
|
||||
- i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
|
||||
- if (i) {
|
||||
- rb_sys_fail("mprotect");
|
||||
- }
|
||||
-#endif
|
||||
|
||||
if (FFI_OK != result)
|
||||
rb_raise(rb_eRuntimeError, "error prepping closure %d", result);
|
23
ruby.spec
23
ruby.spec
|
@ -21,7 +21,7 @@
|
|||
%endif
|
||||
|
||||
|
||||
%global release 105
|
||||
%global release 106
|
||||
%{!?release_string:%global release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}}
|
||||
|
||||
# The RubyGems library has to stay out of Ruby directory tree, since the
|
||||
|
@ -160,6 +160,11 @@ Patch23: ruby-2.6.0-use-larger-keys-for-SSL-tests.patch
|
|||
# https://github.com/ruby/ruby/commit/920b924e5652884064a9529ffbd80d458a46fbc6
|
||||
# https://github.com/ruby/ruby/commit/c1f0daeb6ac5c5414c9a4a58bb778a118006ae1f
|
||||
Patch24: ruby-2.7.0-preview1-IO.select-on-all-platforms-to-wait-for-input-with-recvfr.patch
|
||||
# Use ffi_closure_alloc to avoid segmentation fault by libffi on aarch64.
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1727832
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1721569
|
||||
# https://github.com/ruby/fiddle/pull/20
|
||||
Patch25: ruby-2.6.3-fiddle-1.0.0-ffi-closure-alloc-default.patch
|
||||
|
||||
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
|
||||
Suggests: rubypick
|
||||
|
@ -554,6 +559,7 @@ rm -rf ext/fiddle/libffi*
|
|||
%patch22 -p1
|
||||
%patch23 -p1
|
||||
%patch24 -p1
|
||||
%patch25 -p1
|
||||
|
||||
# Provide an example of usage of the tapset:
|
||||
cp -a %{SOURCE3} .
|
||||
|
@ -566,17 +572,6 @@ cp -a %{SOURCE6} .
|
|||
%build
|
||||
autoconf
|
||||
|
||||
# Overide CFLAGS to avoid below error on aarch64,
|
||||
# removing "-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1" option.
|
||||
# rpm 4.14.2 is used on rhel-8.1.0.
|
||||
# https://src.osci.redhat.com/rpms/rpm/blob/rhel-8.1.0/f/rpm.spec#_31
|
||||
# https://github.com/rpm-software-management/rpm/blob/rpm-4.14.2-release/macros.in#L1008
|
||||
# gcc failed with "annobin: conftest.c: ICE: Should be 64-bit target"
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1720179
|
||||
%ifarch aarch64
|
||||
%define optflags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fasynchronous-unwind-tables -fstack-clash-protection
|
||||
%endif
|
||||
|
||||
%configure \
|
||||
--with-rubylibprefix='%{ruby_libdir}' \
|
||||
--with-archlibdir='%{_libdir}' \
|
||||
|
@ -1205,6 +1200,10 @@ OPENSSL_SYSTEM_CIPHERS_OVERRIDE=xyz_nonexistent_file OPENSSL_CONF='' \
|
|||
%{_mandir}/man5/gemfile.5*
|
||||
|
||||
%changelog
|
||||
* Thu Jul 04 2019 Jun Aruga <jaruga@redhat.com> - 2.6.3-106
|
||||
- Use ffi_closure_alloc to avoid segmentation fault by libffi on aarch64.
|
||||
Resolves: rhbz#1727832
|
||||
|
||||
* Tue Jun 11 2019 Jun Aruga <jaruga@redhat.com> - 2.6.3-105
|
||||
- Update to Ruby 2.6.3 by merging Fedora master branch (commit: 1cc2a49)
|
||||
* Properly generate "ruby(rubygems)" versioned dependencies.
|
||||
|
|
Loading…
Reference in New Issue