-
Notifications
You must be signed in to change notification settings - Fork 44
Use ffi_closure_free by default. #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
We can always use |
|
I have fixed an silly bug in the PR and updated a commit message a bit. Do you think I should update the PR to use the |
Yes.
We should remove |
The current conditionals reflect historic heritage of FFI. Usage of ffi_closure_free should be better default nowadays, because libffi 3.0.5 fixing issues of ffi_closure_free should be widely available.
|
I have update the PR to use the Just FTR, the |
Could you also remove |
Because `ffi_closure_free()` is not used unconditionally, there is no other use for RUBY_LIBFFI_MODVERSION define, so drop its usage.
`ver` variable used to be used to pupulate RUBY_LIBFFI_MODVERSION define. Since the define was removed, the `libffi_dir` variable name should better describe the remaining usage of the variable.
|
I have added commit removing the |
kou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'll merge this.
|
This change was reverted because it fails to build on macOS. Could you check it out? |
This reverts commit ce6caade7c57a505f73086ccd7b33c14f7715f22.
* Revert "[ruby/fiddle] Use ffi_closure_free by default. (#20)" This reverts commit ce6caade7c57a505f73086ccd7b33c14f7715f22. * Revert "[ruby/fiddle] test: use env Hash" This reverts commit 4d844cbaed518743776594fa5ae33b86fe176ad1. * Deprecate taint/trust and related methods, and make the methods no-ops This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. * More fixes for $SAFE/taint post merging * Fix "cannot find the function: strcpy()" error on arm32 on Travis CI. (#2686) This issue happened when `libc.so` and `libm.so` path were not found and `ldd ruby` command also failed to print the shared dependencies in `test/fiddle/helper.rb`. See https://travis-ci.org/ruby/ruby/jobs/611483288#L3018 /home/travis/build/ruby/ruby/build/.ext/common/fiddle/import.rb:299:in `import_function': cannot find the function: strcpy() (Fiddle::DLError) * Set libc6:armhf as a installing dependency explicitly. * Remove arm32 from allow_failures. * Drop executable bit of *.{yml,h,mk.tmpl} * pass appropriate libc path The same as ruby/ruby#2686, but for musl libc. Musl is not named as libc.so.6 so the `ldd` hack implemented some lines below does not work. * Use ffi_closure_free if available * ffi_closure_free is available in the bundled libffi * Fixed never-defined symbol name * use ffi_closure_alloc only with 3.2 or later * always use ffi_closure_alloc on Windows * Fixed a typo * Switch to download libffi source package to github releases from sourceware.org * Use osuosl instead of GitHub releases Because the package provided by GitHub releases is different from sourceware. * Do not set USE_FFI_CLOSURE_ALLOC=1 in fiddle on OpenBSD On OpenBSD, USE_FFI_CLOSURE_ALLOC was always set to 0 previously. In 633a1f15d8228236094ddee12e4e169d655ec49e, the code was modified in a way that it ended up being set to 1 on OpenBSD. However, that results in SIGABRT when running make test-all, inside ffi_closure_free. Setting USE_FFI_CLOSURE_ALLOC back to 0 fixes the issue. * Show libffi version only if set * Fix helper to not assume glibc * `Dir.glob` always returns an array It is not needed to test itself, but the element should be tested instead. Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org> Co-authored-by: Jeremy Evans <code@jeremyevans.net> Co-authored-by: Jun Aruga <junaruga@users.noreply.github.com> Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com> Co-authored-by: 卜部昌平 <shyouhei@ruby-lang.org> Co-authored-by: Paul Jordan <paullj1@gmail.com>
TLDR; Set
USE_FFI_CLOSURE_ALLOC=1by default for better compatibility and improved SELinux support [3]Recently, we were trying to build Ruby 2.6 on RHEL8, but with the most recent version of libffi including patch for libffi/libffi#470, we started to observe crashes on AArch64 such as:
The simplest reproducer is:
As far as I can tell, there were similar issues already, such as [1, 2]. We were considering to modify the build options to include
-DUSE_FFI_CLOSURE_ALLOC=1, but now I think this should be changed upstream by defauld for the following reasons:ffi_closure_freeshould not be used on the first place. It seems that the conditional there is just heritage, where older versions of libffi have not supported theffi_closure_freefunction everywhere.ffi_closure_freeshould provide better SELinux compatibility [3]ffi_closure_freeused.The PR changes to use the
ffi_closure_freeevery time except for the old libffi. Should there be some exceptions, it should be properly understood and documented.