Sketchup 2017 crashes when FFI is loaded in Windows 10




I’m trying to load the FFI gem version (ffi-1.9.17-x64-mingw32) in Windows 10, Sketchup 2017 (maintenance build - 17.2.2555).

Edit note: In my old post, I had only loaded the file corresponding to ruby version 2.2 and I can see that was incomplete frm FFI perspective, and hence now loaded the whole of FFI gem.

As I execute the below command of getting a memory pointer, SketchUp throws a bug splat…

$: << File.join('C:\Ruby22-x64\lib\ruby\gems\2.2.0\gems\ffi-1.9.17-x64-mingw32\lib')

require 'ffi'

float_ptr = :float, 1

But giving the same command outside in ruby IRB in version 2.2.4 creates the pointer just fine.
Any help is greatly appreciated.


(1) Instructions on properly formatting error text in the forum ...

Your error report text is incorrectly formatted for the forum. (The forum engine stripped out the error message because it thought it was an invalid HTML element bracketed between < and > characters, which I’ve escaped with leading \ here.)
Please edit (pencil icon) your post, and insert triple backtick delimiter lines, before and after the error text block. (The backtick key is to the left of the 1 key just above the TAB on US keyboards):

# error text here

(2) SketchUp comes with it’s own specially compiled edition of Ruby and the standard library.

I would advise you to use the Fiddle library that comes with SketchUp’s Ruby library.

Loading “fiddle.rb” will load “” which loads
SketchUp 20nn/Tools/RubyStdLib/platform_specific/libffi-6.dll
most likely using a LoadLibrary call. Since Ruby is all opensource, you can read the source:


Thanks for the tip on error text Dan, I have edited my above post.

and on Fiddle,

Yes we are aware of fiddle as alternate, but we have a big library built on top of FFI, and we are in a stage to release the product in Sketchup 2017 but this FFI bug splat is like a show stopper for us now. Re-writing our library in fiddle might take some amount of time, we are trying to see if there is something from our side which can be fixed on this bug splat case.

  1. FFI in 2017+Win 7 combination works just fine,
  2. FFI in 2016 + Win 10 Combination works fine

FFI in 2017 + Win 10 => Bug splat

If this is a Sketchup-only-fix-able issue, we will move on with fiddle option… :worried:



FYI, Gems for SketchUp are installed in a SketchUp specific location (purposely kept separate from any “system” Ruby installations.)

From inside SketchUp’s Ruby console you can see the location via:

puts ENV["GEM_HOME"]
puts ENV["GEM_PATH"]


require "pp"
pp ENV

The folder name is “Gems” for 32-bit installations, and “Gems64” for 64-bit installations.

BUT, … this only works well for pure Ruby gems.

SketchUp Ruby and it’s rubygems extension, is not linked up with Ruby’s DevKit, so cannot compile C gems “on the fly” like a normal “system” Ruby install (with the proper DevKit) can.

Sometimes what coders do is provide precompiled 32-bit and 64-bit gems, that are repackaged as a SketchUp extension, or as support libraries within their extension. It may be helpful to tweak the gem namespace(s) so that they are encapsulated inside your toplevel author (or company) namespace module.

We have discussed this both here (in this category) and over at SketchUcation in the Developers forum.


In SU2017 under Win10, I get what looks like a good gem install in SketchUp’s console …

Gem::install "ffi"
#=> [#<Gem::Specification:0xf08816f688 ffi-1.9.25-x64-mingw32>]

require 'ffi'
#=> true

… but then …

float_ptr = :float, 1
#=> SPLAT!

I sent in a BugSplat report as well referencing this topic thread.
The response said that perhaps SU2018 would fix the issue.

Same crash in SU2018.