Forum: Ruby Help on Ruby Segmentation Problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3083ca8f0496edaac2fa10c20630d0bc?d=identicon&s=25 Newb Newb (newb)
on 2009-04-20 12:05
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);

}
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2009-04-20 12:44
(Received via mailing list)
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.
3083ca8f0496edaac2fa10c20630d0bc?d=identicon&s=25 Newb Newb (newb)
on 2009-04-20 13:13
Nobuyoshi Nakada wrote:
> 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...
3083ca8f0496edaac2fa10c20630d0bc?d=identicon&s=25 Newb Newb (newb)
on 2009-04-20 14:30
Newb Newb wrote:
> Nobuyoshi Nakada wrote:
>> 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
3083ca8f0496edaac2fa10c20630d0bc?d=identicon&s=25 Newb Newb (newb)
on 2009-04-21 12:27
Newb Newb wrote:
> Newb Newb wrote:
>> Nobuyoshi Nakada wrote:
>>> 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
This topic is locked and can not be replied to.