[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libffi - updates needed?



Hi David!

On Mon, Apr 16, 2012 at 06:28:55PM +0100, Dr. David Alan Gilbert wrote:
>* Steve McIntyre (steve@einval.com) wrote:
>> Hi,
>> 
>> I'm looking through the archive for packages using libffi. There's a
>> problem with libffi and variadic functions that has been recently
>> fixed - see
>> 
>>   http://lists.debian.org/debian-arm/2012/03/msg00108.html
>> 
>> for more information. So far, we only expect symptoms to show up on
>> armhf *but* it might be more widespread. Until recently, libffi didn't
>> support variadic functions properly. That's now been fixed in libffi,
>> but there's an extra API call necessary in places where variadics are
>> used.
>
>Ah, you've picked up this fun one :-)

Yup, Marcus pointed it out to me and I've started tracking it again. :-)

>As I remember most other archs 'get away with it' often
>because they do silly things like pass values in registers and 
>on the stack and still offset the stack for the ones passed in
>registers.   I don't know if anyone has got around to doing
>other backends other than armhf since I touched it, but
>I think we knew there were some of the MIPS varients that could
>do with it.

Right. Are these the newer mips ABI variants like n32/n64, do you
know? If so, I'm not so worried just yet!

>> Looking at gcc-4.6 and gcc-4.7, I can see that the embedded copies of
>> libffi are too old for this fix. I don't see a build-dep on
>> libffi-dev, whish suggests that they're using these embedded copies
>> rather than the system version. A couple of questions here: I'm
>> curious why this is? If it's definitely necessary, could we update
>> those embedded copies to a more recent libffi with the change
>> included?
>> 
>> Even beyond that, there are quite likely to be changes that would need
>> to be made in the gcc source to use the new ffi_prep_cif_var()
>> function. My scan of the archive shows ffi_prep_cif() shows up / is
>> used in:
>> 
>>  gcc-4.6
>>  gcc-snapshot
>>  gcj-4.[467]
>> 
>> at least. Can you help please? 
>
>However, it's pretty rare for things to actually use variadics with
>libffi, it's even rarer for them to pass floats; although someone had
>asked for libffi to be fixed for armhf, I could never find someone to
>say what app was broken; there were some mumblings about Java, but even
>there I didn't actually find someone with a test.  I think some Python
>ctype examples looked broken.

Yes, I've seen that too.

>The other nasty to keep in mind is that where the libffi
>calls come from some scripting language glue, it's not clear
>that the languages/glue have the syntax to express that they're calling
>a variadic function, so it might need language changes.
>(I never managed to get any response out of the CType list).

Yes. I looked for a response to your original mail there and couldn't
find any in list archives; I'm guessing that's because you didn't get
one?

The Haskell packages that showed up in my scan of the Debian archive
are apparently all OK; ghc has a habit of embedding large chunks of
the core in everything it builds, and the ffi calls there are expected
to be safe (no variadics).

Otherwise, as you say: I'm looking at a number of language
implementations where it's (a) not clear if they'll ever do variadics
(b) if they *might* use variadics, it'll be because somebody is
calling through a generic helper function with no current way of
determining if the callee is variadic or not. Yay... :-/

-- 
Steve McIntyre, Cambridge, UK.                                steve@einval.com
Who needs computer imagery when you've got Brian Blessed?


Reply to: