fiddle pushes arguments in a wrong format
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:
<"1349"> expected but was
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.¶
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?
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?