summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2020-12-18 19:06:41 +0100
committerLars Kanis <lars@greiz-reinsdorf.de>2020-12-18 19:06:41 +0100
commit3aa6b25f5423a64ad4afa7f2a5a5855483bae3c2 (patch)
tree578e284ce3dcc29eb6b310b130f7eb30d068dcd6
parente3f2cf9b82055709ddbeecbf77810f43438c4b64 (diff)
downloadffi-3aa6b25f5423a64ad4afa7f2a5a5855483bae3c2.tar.gz
Fix possible segfault in combination with fiddle or other libffi using gems
Fiddle can crash when used together with ffi and it's builtin libffi. This happens because fiddle is linked to system libffi, but ffi is linked to builtin libffi. Depending on which of these gems is loaded first, they link to the wrong runtime library. This issue is similar to the issue in nokogiri: https://github.com/sparklemotion/nokogiri/issues/1959 Fixes #835
-rw-r--r--ext/ffi_c/extconf.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/ffi_c/extconf.rb b/ext/ffi_c/extconf.rb
index 8d8a602..cdeaa9b 100644
--- a/ext/ffi_c/extconf.rb
+++ b/ext/ffi_c/extconf.rb
@@ -50,6 +50,11 @@ if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'rbx'
else
$defs << "-DHAVE_FFI_PREP_CIF_VAR"
$defs << "-DUSE_INTERNAL_LIBFFI"
+
+ # Ensure libffi symbols aren't exported when using static libffi.
+ # This is to avoid interference with other gems like fiddle.
+ # See https://github.com/ffi/ffi/issues/835
+ append_ldflags "-Wl,--exclude-libs,ALL"
end
ffi_alloc_default = RbConfig::CONFIG['host_os'] =~ /darwin/i && RbConfig::CONFIG['host'] =~ /arm/i