When running similar ruby code (using the PDFlib extension) without Rails it works fine. Also Ruby 1.8 has no problem and I have tested the same thing on Linux (32bit), there it works fine too.
Building a wrapper from this and using it still crashes rails. The coredump looks like this:
MyBigMac (1)$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-25 15:08:28] INFO WEBrick 1.3.1
[2011-11-25 15:08:28] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-11-25 15:08:28] INFO WEBrick::HTTPServer#start: pid=10348 port=3000
Trace/BPT trap: 5 (core dumped)
MyBigMac (1)$ gdb /Users/rjs/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
/cores/core.10348
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared
libraries .... done
Reading symbols for shared libraries . done
Reading symbols for shared libraries
..............................................................................................................................
done
#0 0x00007fff8ee69df2 in select$DARWIN_EXTSN ()
(gdb) bt
#0 0x00007fff8ee69df2 in select$DARWIN_EXTSN ()
#1 0x0000000100186ca1 in do_select (n=7, read=0x102d6ff40, write=0x0,
except=0x0, timeout=0x7fff5fbfde00) at thread.c:2516
#2 0x00000001000669cc in select_internal [inlined] () at
/Users/rjs/.rvm/src/ruby-1.9.2-p290/io.c:7241
#3 0x00000001000669cc in select_call (arg=<value temporarily unavailable, due
to optimizations>) at io.c:7314
#4 0x000000010003ecdf in rb_ensure (b_proc=0x1000664b0 <select_call>,
data1=140734799798368, e_proc=0x10005ed50 <select_end>, data2=140734799798368)
at eval.c:743
#5 0x000000010005f61e in rb_f_select (argc=<value temporarily unavailable, due
to optimizations>, argv=<value temporarily unavailable, due to optimizations>,
obj=<value temporarily unavailable, due to optimizations>) at io.c:7360 #6 0x000000010017bae3 in vm_call_cfunc [inlined] () at
/Users/rjs/.rvm/src/ruby-1.9.2-p290/vm_insnhelper.c:402
#7 0x000000010017bae3 in vm_call_method (th=0x100301af0, cfp=0x1004ffad8,
num=4, blockptr=0x1, flag=0, id=<value temporarily unavailable, due to
optimizations>, me=0x10034fe30, recv=4303817080) at vm_insnhelper.c:524
#8 0x0000000100166e73 in vm_exec_core (th=0x100301af0, initial=<value
temporarily unavailable, due to optimizations>) at insns.def:1006
#9 0x000000010016f933 in vm_exec (th=0x100301af0) at vm.c:1147
#10 0x000000010017cde0 in rb_yield (val=4317168960) at vm.c:558
...
So it looks like it is not specific to some "Third-Party-Extension".
I can see the problem on Mac (10.6/10.7), with ruby 1.9 running with Rails 3 (3.0/3.1). Ruby 1.9 without rails is fine, Ruby 1.8 (even with Rails 3.x is fine).
I would be happy about any hint how to proceed on this, so that it is possible to use a C-extension with Ruby-1.9 on Mac.