Project

General

Profile

Bug #3487

fiddle pushes arguments in a wrong format

Added by yugui (Yuki Sonoda) over 9 years ago. Updated over 8 years ago.

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

Description

=begin
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:


Hi,

Here's a log:
1) Failure:
test_qsort(DL::TestImport)
[/Users/yugui/dev/ruby/mri/1.9.2/test/dl/test_import.rb:148]:
<"1349"> expected but was
<"9341">.

== 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:

  • https://trac.macports.org/ticket/25439 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
In http://twitter.com/tenderlove/status/17103559909:

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?
=end

History

#1

Updated by mame (Yusuke Endoh) over 9 years ago

  • Status changed from Assigned to Closed

=begin
Fixed at r28465.

ML integration seems not to work. Closed manually.

--
Yusuke Endoh mame@tsg.ne.jp
=end

Also available in: Atom PDF