B
barabba
Hi,
I am using ruby to test and develop my legacy C code. I packed it
inside a ruby extension as dll under windows. I am using visual
studio 6 to debug my extension.
The process works very well, but when I make a mistake in my C code
ruby abort without stack trace and it is difficult for me to find the
reason.
Here a trivial example. I have exported the buggy function
foo_thread_handler to ruby:
void foo_thread_handler()
{
while(1)
{
// a thread task
mystruct* pCrash = 0; // null pointer usage
pCrash->len = 555; // crash with 0xC0000005: Access
Violation.
do_realstuff(); // do real stuff
// call a function inside ruby to get back to the scheduler
rb_something()
}
}
and in ruby:
require 'myextension'
Thread.new {
begin
Myextension::foo_thread_handler()
rescue Exception => detail
puts " c extension code error"
end
}
def rb_something
puts "I am alive"
end
How can avoid ruby to silent abort when pCrash->len = 555; is
executed?
I am interested on stack trace, because it is not created, or an
assert to identify the code that make a crash.
Usually such exceptions are handled inside visual studio, but if I run
ruby inside it, in order to debug my extension, this doesn't happens.
I think to rebuild ruby and modify error.c to avoid abort() call
inside rb_bug(), but I am looking for a better solution.
Regards,
Igor
I am using ruby to test and develop my legacy C code. I packed it
inside a ruby extension as dll under windows. I am using visual
studio 6 to debug my extension.
The process works very well, but when I make a mistake in my C code
ruby abort without stack trace and it is difficult for me to find the
reason.
Here a trivial example. I have exported the buggy function
foo_thread_handler to ruby:
void foo_thread_handler()
{
while(1)
{
// a thread task
mystruct* pCrash = 0; // null pointer usage
pCrash->len = 555; // crash with 0xC0000005: Access
Violation.
do_realstuff(); // do real stuff
// call a function inside ruby to get back to the scheduler
rb_something()
}
}
and in ruby:
require 'myextension'
Thread.new {
begin
Myextension::foo_thread_handler()
rescue Exception => detail
puts " c extension code error"
end
}
def rb_something
puts "I am alive"
end
How can avoid ruby to silent abort when pCrash->len = 555; is
executed?
I am interested on stack trace, because it is not created, or an
assert to identify the code that make a crash.
Usually such exceptions are handled inside visual studio, but if I run
ruby inside it, in order to debug my extension, this doesn't happens.
I think to rebuild ruby and modify error.c to avoid abort() call
inside rb_bug(), but I am looking for a better solution.
Regards,
Igor