G
Godot
Hi,
This following problem is most likely due to my own
misunderstandings, but I've not been able to resolve it after staring
and scratching my head for quite a while. Here it is:
---------------Start code---------------
#include <ruby.h>
#include <iostream>
#include <string>
using namespace std;
void dontCrash(string s)
{
VALUE test = rb_str_new2( s.c_str( ) );
rb_gc_register_address(&test);
rb_gc( ); // Test if gc gets corrupted
rb_p( rb_str_new2(" stuff!!! ") );
rb_p( test );
rb_gc_unregister_address(&test);
}
int main ()
{
ruby_init ();
ruby_init_loadpath ();
dontCrash("puts 'test'");
ruby_finalize();
}
-------------- End code --------------------
The code (as reported by valgrind) always crashes on rb_gc( ).
Without the rb_gc( ), the code runs fine. It also crashes when
rb_register_address isn't called. This error has really got me
stumped, so any help is greatly appreciated.
Thanks,
-Godot
This following problem is most likely due to my own
misunderstandings, but I've not been able to resolve it after staring
and scratching my head for quite a while. Here it is:
---------------Start code---------------
#include <ruby.h>
#include <iostream>
#include <string>
using namespace std;
void dontCrash(string s)
{
VALUE test = rb_str_new2( s.c_str( ) );
rb_gc_register_address(&test);
rb_gc( ); // Test if gc gets corrupted
rb_p( rb_str_new2(" stuff!!! ") );
rb_p( test );
rb_gc_unregister_address(&test);
}
int main ()
{
ruby_init ();
ruby_init_loadpath ();
dontCrash("puts 'test'");
ruby_finalize();
}
-------------- End code --------------------
The code (as reported by valgrind) always crashes on rb_gc( ).
Without the rb_gc( ), the code runs fine. It also crashes when
rb_register_address isn't called. This error has really got me
stumped, so any help is greatly appreciated.
Thanks,
-Godot