Bug #3487


fiddle pushes arguments in a wrong format

Added by yugui (Yuki Sonoda) almost 12 years ago. Updated about 11 years ago.

Target version:
ruby -v:
ruby 1.9.2dev (2010-06-25 revision 28427) [i386-darwin9.8.0]


DL::TestImport#test_qsort fails on Mac OS X 10.5 when

  • Ruby is compiled with the universal binary version of libffi.
    • It does not reproduce even when Ruby is dynamically linked with the libffi, if Ruby is compiled with a libffi which is not universal binary.
  • And ruby is compiled for i386.

and here is a copy of the mail I sent to report the problem to tenderlove:


Here's a log:

  1. Failure:
    <"1349"> expected but was

== Problem
The problem is fiddle regards rb_ffi_type_of(long) as ffi_type_sint64
even if complied for i386 but not for x86_64.
So libffi set up a wrong stack for qsort.

There are two reasons. The first reason is a problem of macports:

    MacPorts installs a invalid header ffitarget.h, so
    ext/fiddle/extconf.rb fails to detect libffi installed by MacPorts.
    This happens when
  • MacPorts uses +universal variant for libffi
  • fiddle is compiled with the universal libffi
  • universal_archs option for MacPorts includes both ppc and i386

The other reason is /usr/include/ffi/ffitarget.h on OSX Leopard.
OSX Leopard uses i386 arch by default, however, the ffitarget.h is
configured as sizeof(long)==8.

fiddle uses /usr/include/ffi/ffi.h instiead of
/opt/local/lib/libffi-3.0.9/include/ffi.h and it uses

define ffi_type_slong ffi_type_sint64.

== Reproduction

I can't seem to reproduce.

I think you uses OSX Snow Leopard, so gcc compiles ruby for x86_64 by
default. sizeof(long) == 8 is correct in this case.
Could you try ./configure --with=arch=i386 for Ruby's configuration?

== Solution
I succeeded to avoid this problem by overwriting the aliases based on
Ruby's configuration as the following patch:

I think it is enough because libffi seems to assume CHAR_BIT == 8.
What do you think?

Actions #1

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Status changed from Assigned to Closed

Fixed at r28465.

ML integration seems not to work. Closed manually.

Yusuke Endoh


Also available in: Atom PDF