I've been able to call Ruby functions from C but am getting a core dump when
trying to call the Ruby function from a thread.  Here is sample code that
duplicates the problem:

Platform is RedHat (x86) 6.0

gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)  

glibc 2.1.2

The program seg faults with this message:

ruby:0: stack level too deep (SystemStackError)
ruby: [BUG] Segmentation fault
Aborted (core dumped)

-geoff

-------------test.c-------------
#include <pthread.h>
#include "ruby.h"  

void *ruby_thread(void *arg) {

        while (1)  {
                rb_funcall(module, rb_intern("test"), 0);
        }


}

int main(void) {

        pthread_t thread_id;
        int status;

        ruby_init();
        module = rb_require("test.rb");

        status = pthread_create(&thread_id, NULL, ruby_thread, NULL);
                                                                                        pthread_join(thread_id, NULL);
        return 0;
}

------------test.rb-----------
def test
        print "hello\n"
end