Subject:
[ruby-ffi] Re: Possible issues with Ruby FFI on ARM processor (Raspberry PI)
From:
Wayne Meissner
Date:
2/25/13 3:49 PM
To:
ruby-ffi@googlegroups.com


Off the top of my head, a couple of issues could be:

1) data sizes/layout.  Verify that the sizes of all your FFI structs match the C ones, and that the sizes & offsets of members match.

2) Given it only crashes on exit, it could be some sort of GC/finalizer interaction.  Set all the MemoryPointer instances, including the ones backing the structs to autorelease=false - this causes FFI to disown the memory, so it won't try to free it.

Do the same for any strings you pass in to the API - :string parameters in particular could be a problem if the library persists the pointer passed in instead of copying the string contents - :string params are temporary - the memory allocated only lasts until the function returns.

3) Endian-ness issues in ruby-ffi itself.  Is that arm arch big-endian or little-endian?

On Monday, 25 February 2013 00:24:00 UTC+10, Kim Burgestrand wrote:
I’ve been having some issues running one of my gems (http://rubygems.org/gems/spotify) successfully on Raspberry PI, using the soft float debian “weezy” OS, downloadable from http://www.raspberrypi.org/downloads on cruby 1.9.3 (ruby 1.9.3p385 (2013-02-06 revision 39114) [armv6l-linux-eabi]).

I’ve been troubleshooting some, and created one example written in C, and one equivalent example written in Ruby using FFI. My suspicion was that they would behave identically, but the ruby code will sometimes segfault on exit, while the C code does not.

Now, I’m not entirely certain that the two examples are completely equivalent, so I’d be grateful for any pair of critical eyes on the two code samples: https://gist.github.com/Burgestrand/7b691591af20c29d6849

My questions are:

1. Are the two (C vs. Ruby) samples really equivalent?
2. Any ideas for further troubleshooting?

— Kim

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.