Bug in Ruby Ext to C or it is me?

Compile this, link it with ruby lib, execute with a small
ruby program like this one :

puts "Hello World from main Ruby Thread"

And explain why there is a core dump !

– jc

#include <ruby.h>
#include <unistd.h>

static VALUE request_thread (void * data)
{
while (1) {
printf (“thread begin\n”);
sleep(1);
printf(“Thread end\n”);
rb_thread_schedule();
}
return Qtrue;
}

int main (int argc, char * argv[])
{
ruby_init();
ruby_options(argc, argv);
rb_thread_create (request_thread, NULL);

ruby_run();

return 0;
}

I think this should be:
static VALUE request_thread(void * data, void * th);

I think it would be nice if in intern.h rb_thread_create were declared
to take a function pointer to a function taking two pointers, instead of
taking ANYARGS. The ruby API is more type-safe than it used to be, but
still leaves something to be desired when it comes to type safety with
function pointers.

Paul

···

On Wed, Sep 11, 2002 at 12:14:13AM +0900, JCW wrote:

static VALUE request_thread (void * data)

Hi,

···

In message “Bug in Ruby Ext to C or it is me ?” on 02/09/11, JCW weilljc@club-internet.fr writes:

Compile this, link it with ruby lib, execute with a small
ruby program like this one :

puts “Hello World from main Ruby Thread”

And explain why there is a core dump !

It works for me. Could you tell me about your platform and the
version of Ruby you’re using.

						matz.

Hi,

···

At Wed, 11 Sep 2002 00:14:13 +0900, JCW wrote:

Compile this, link it with ruby lib, execute with a small
ruby program like this one :

puts "Hello World from main Ruby Thread"

And explain why there is a core dump !

Worked cleanly.


Nobu Nakada

I bet you have compiled with stack-frame-pointer ommision turned on. This is done with -fomit-frame-pointer in gcc, and is the default with MSVC when you choose the “Maximise Speed” optimisation. Frame-pointer ommision does not work with ruby exceptions or threads.

Lorien Dunn

···

On Wed, 11 Sep 2002 00:14:13 +0900 weilljc@club-internet.fr (JCW) wrote:

Compile this, link it with ruby lib, execute with a small
ruby program like this one :

puts "Hello World from main Ruby Thread"

And explain why there is a core dump !

– jc

#include <ruby.h>
#include <unistd.h>

static VALUE request_thread (void * data)
{
while (1) {
printf (“thread begin\n”);
sleep(1);
printf(“Thread end\n”);
rb_thread_schedule();
}
return Qtrue;
}

int main (int argc, char * argv[])
{
ruby_init();
ruby_options(argc, argv);
rb_thread_create (request_thread, NULL);

ruby_run();

return 0;
}

Hi,

···

At Thu, 12 Sep 2002 08:50:04 +0900, Lorien Dunn wrote:

I bet you have compiled with stack-frame-pointer ommision
turned on. This is done with -fomit-frame-pointer in gcc, and
is the default with MSVC when you choose the "Maximise Speed"
optimisation. Frame-pointer ommision does not work with ruby
exceptions or threads.

I usually use gcc with that option, rather it may be concerned
with platform and compiler version.


Nobu Nakada

matz@ruby-lang.org (Yukihiro Matsumoto) wrote in message news:1031671988.807899.5138.nullmailer@picachu.netlab.jp

Hi,

Compile this, link it with ruby lib, execute with a small
ruby program like this one :

puts “Hello World from main Ruby Thread”

And explain why there is a core dump !

It works for me. Could you tell me about your platform and the
version of Ruby you’re using.

  					matz.

Platform Solaris Compiler cc (natif Sun Compiler)
Tru-OS-64 Compiler cc (natif Compaq/HP Conpiler)

I’ll try it on Linux and with gcc.

Best Regards,

JC

···

In message “Bug in Ruby Ext to C or it is me ?” > on 02/09/11, JCW weilljc@club-internet.fr writes: