Help on Ruby Segmentation Problem


#1

hi all…
I extend ruby with C.
I m new to these kind of stuffs…
I integrate my dll namely prov.all into C program namely prov.c
afterthat i call those c functions through ruby .

irb(main):001:0> require ‘prov1’
=> true
irb(main):002:0> include Prov
=> Object
irb(main):003:0> Prov::load
=> true
irb(main):004:0> Prov::init_engine
(irb):4: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-13) [i386-mswin32]

when i call Prov::init_engine method it gets crashed.

could you pls point me out which causes segmentation Problem.

Thanks in advance.

below is my prov1.c code

#include “windows.h”

#include “ruby.h”

#include “prov.h”

#define _D(string) {OutputDebugString(string);}

VALUE Prov;

void _textline(const char s, int len)
//
***********************************
{
_D(s);
}

static VALUE p_load(VALUE self )
//******************************
{

   prov_load();

return Qtrue;
}

static VALUE p_init(VALUE self)
//*****************************
{
_D("-> init");

    prov_set_textline_callback(_textline);

    prov_renderInit();

//return Qtrue;
}

static VALUE p_parse(VALUE self, VALUE string_to_parse)
//*****************************************************
{

_D(StringValuePtr(string_to_parse));
return prov_parse(StringValuePtr(string_to_parse));

}

static VALUE pr_render( VALUE self )
//**********************************
{

_D("-> render");

prov_render(0);
//return Qtrue;
}

void Init_prov1()
//***************
{
Prov = rb_define_module( “Prov” );
rb_define_method(Prov, “load”, p_load, 0);
rb_define_method( Prov, “init_engine”, p_init, 0 );
rb_define_method(Prov, “parse”, p_parse, 1);
rb_define_method(Prov, “render”, pr_render, 0);

}


#2

Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb N. wrote in [ruby-talk:334453]:

when i call Prov::init_engine method it gets crashed.

could you pls point me out which causes segmentation Problem.

Probably:

a. bug in prov_set_textline_callback() or prov_renderInit(),

b. because p_init() returns nothing ispite of declared as
VALUE, #init_engine returns non-object, and irb tried to
call #inspect on it to display the result.


#3

Nobuyoshi N. wrote:

Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb N. wrote in [ruby-talk:334453]:

when i call Prov::init_engine method it gets crashed.

could you pls point me out which causes segmentation Problem.

Probably:

a. bug in prov_set_textline_callback() or prov_renderInit(),

b. because p_init() returns nothing ispite of declared as
VALUE, #init_engine returns non-object, and irb tried to
call #inspect on it to display the result.

Very much thanks for the reply …

how can i get rid of those errors …

any advices…


#4

Newb N. wrote:

Newb N. wrote:

Nobuyoshi N. wrote:

Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb N. wrote in [ruby-talk:334453]:

when i call Prov::init_engine method it gets crashed.

could you pls point me out which causes segmentation Problem.

Probably:

a. bug in prov_set_textline_callback() or prov_renderInit(),

b. because p_init() returns nothing ispite of declared as
VALUE, #init_engine returns non-object, and irb tried to
call #inspect on it to display the result.

Very much thanks for the reply …

how can i get rid of those errors …

any advices…

Hi…

in my code prov_renderInit();

method causes the segmentation error…

so how should i call that prov_renderInit() function in Ruby

Pls advice

hi all…

I m extending ruby with C.

my init_engine method causes segmentation problem

I want to look for stack trace to solve the error.

could you pls help me how i can get full stack trace for the error…

Thanks For Your Consideration


#5

Newb N. wrote:

Nobuyoshi N. wrote:

Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb N. wrote in [ruby-talk:334453]:

when i call Prov::init_engine method it gets crashed.

could you pls point me out which causes segmentation Problem.

Probably:

a. bug in prov_set_textline_callback() or prov_renderInit(),

b. because p_init() returns nothing ispite of declared as
VALUE, #init_engine returns non-object, and irb tried to
call #inspect on it to display the result.

Very much thanks for the reply …

how can i get rid of those errors …

any advices…

Hi…

in my code prov_renderInit();

method causes the segmentation error…

so how should i call that prov_renderInit() function in Ruby

Pls advice