Help on Ruby Segmentation Problem

N

Newb Newb

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);

}
 
N

Nobuyoshi Nakada

Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb Newb 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.
 
N

Newb Newb

Nobuyoshi said:
Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb Newb 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...
 
N

Newb Newb

Newb said:
Nobuyoshi said:
Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb Newb 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
 
N

Newb Newb

Newb said:
Newb said:
Nobuyoshi said:
Hi,

At Mon, 20 Apr 2009 19:06:40 +0900,
Newb Newb 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top