unable to resolve type 'size_t' (TypeError) #137

johnae opened this Issue Aug 27, 2011 · 8 comments


None yet
6 participants

johnae commented Aug 27, 2011

I'm getting this error when trying out fssm and rb-inotify and it seems to come from ffi. The full error message is:

/usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/ffi-1.0.9/lib/ffi/types.rb:45:in `find_type': unable to resolve type 'size_t' (TypeError)
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/ffi-1.0.9/lib/ffi/library.rb:287:in `find_type'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/ffi-1.0.9/lib/ffi/library.rb:116:in `block in attach_function'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/ffi-1.0.9/lib/ffi/library.rb:116:in `map!'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/ffi-1.0.9/lib/ffi/library.rb:116:in `attach_function'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/rb-inotify-0.8.6/lib/rb-inotify/native.rb:28:in `<module:Native>'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/rb-inotify-0.8.6/lib/rb-inotify/native.rb:9:in `<module:INotify>'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/rb-inotify-0.8.6/lib/rb-inotify/native.rb:3:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.2-p290-patched/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.2-p290-patched/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/rb-inotify-0.8.6/lib/rb-inotify.rb:1:in `<top (required)>'
    from /usr/local/rvm/rubies/ruby-1.9.2-p290-patched/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.2-p290-patched/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-1.9.2-p290-patched/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/fssm-0.2.7/lib/fssm/support.rb:72:in `rb_inotify?'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/fssm-0.2.7/lib/fssm/support.rb:11:in `usable_backend'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/fssm-0.2.7/lib/fssm/support.rb:32:in `backend'
    from /usr/local/rvm/gems/ruby-1.9.2-p290-patched/gems/fssm-0.2.7/lib/fssm.rb:36:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:33:in `require'
    from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from filetail.rb:1:in `<main>'

@terceiro terceiro added a commit to terceiro/ffi that referenced this issue Oct 1, 2011

@terceiro terceiro Complete fix for platform detection
Test for GNU systems by checking whether the GNU libc is available.
Also added a spec that reproduces #137.

kostya commented Oct 5, 2011

same on freebsd with code: FFI::MemoryPointer.new(:size_t)


terceiro commented Oct 6, 2011

@kostya, are you still seeing this with the current master branch, or with the latest release (1.0.9)?

kostya commented Oct 6, 2011

ree 1.8.7, it was in 1.0.9, master will test soon.

kostya commented Oct 9, 2011

master is ok

mderar commented Apr 18, 2012

I'm getting this error on an Arm based machine:

RbConfig::CONFIG['host_cpu'] = armv7l
RbConfig::CONFIG['host_os'] = linux-gnueabi
glibc 2.15

Bluebie commented May 31, 2012

I'm also having this issue on arm. When I clone and rake the main branch of this repo I get a test failure:


  1) Custom type definitions detects the correct type for size_t
     Failure/Error: lambda do
       expected no Exception, got #<TypeError: unable to resolve type 'size_t'>
     # ./spec/ffi/typedef_spec.rb:80:in `block (2 levels) in <top (required)>'

Finished in 42.77 seconds
4805 examples, 1 failure

Failed examples:

rspec ./spec/ffi/typedef_spec.rb:79 # Custom type definitions detects the correct type for size_t
rake aborted!
Command failed with status (1): [/usr/bin/ruby -w -Ilib -Ibuild/armv5tel-li...]

This is running on the Raspberry Pi via the Arch Linux alarm distro provided on http://www.raspberrypi.org completely up to date, building against ruby 1.9.3p194 (2012-04-20 revision 35410) [armv5tel-linux-eabi]. I've also tried the ffi gems, versions 1.0.0, 1.0.1, 1.0.9, and 1.0.11 - none of these work with code that uses size_t, like the libusb gem I'm trying to use.


ghost commented Jul 29, 2012

Can you try the latest ffi master? It should normalize all of arm* to 'arm', and use the one set of types.

Bluebie commented Aug 7, 2012

Yep! Works now :D

ghost closed this Sep 22, 2012

Hi, I've just come across this same issue on a NetBSD Xen install. On that, RbConfig::CONFIG['host_os'] reports "netbsdelf". If I add the following to lib/ffi/platform.rb

when /netbsd/

it works fine. I.e. this is as per how FreeBSD and OpenBSD are configured. I could put in a pull request for this, but thought I'd check first if there was a better fix?

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment