So, i'm trying to compile 'n run a simple app with Ruby embedded in C,
this is the code:
// test.c
#include <ruby.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
ruby_init();
rb_eval_string("puts 'hello world'");
ruby_finalize();
return 0;
}
Then, I compile:
g++ -BC:/Ruby193/bin -lmsvcrt-ruby191 -o hello.exe test.c
(Run ok)
an run:
hello.exe
(eval):1: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]
-- Control frame information
···
-----------------------------------------------
c:0006 p:---- s:0014 b:0014 l:000013 d:000013 CFUNC :write
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 CFUNC :puts
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :puts
c:0003 p:0011 s:0006 b:0006 l:0022fc d:000005 EVAL (eval):1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0022fc d:0022fc TOP
-- Ruby level backtrace information
----------------------------------------
(eval):1:in `<main>'
(eval):1:in `puts'
(eval):1:in `puts'
(eval):1:in `write'
-- C level backtrace information
-------------------------------------------
C:\Windows\SysWOW64\ntdll.dll(NtWaitForSingleObject+0x15) [0x775df861]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObjectEx+0x43)
[0x759b1184]
C:\Windows\syswow64\kernel32.dll(WaitForSingleObject+0x12) [0x759b1138]
C:\Users\Gab\Desktop\Programacao\Ruby C
API\msvcrt-ruby191.dll(rb_vm_bugreport+0xf9) [0x62e5acc9]
C:\Users\Gab\Desktop\Programacao\Ruby C
API\msvcrt-ruby191.dll(rb_name_err_mesg_new+0x17a) [0x62d3a68e]
C:\Users\Gab\Desktop\Programacao\Ruby C
API\msvcrt-ruby191.dll(rb_bug+0x2f) [0x62d3b3ef]
C:\Users\Gab\Desktop\Programacao\Ruby C
API\msvcrt-ruby191.dll(rb_check_safe_str+0x1a4) [0x62ded27c]
[0x00401262]
C:\Windows\syswow64\kernel32.dll(CheckForReadOnlyResource+0x3bf
[0x759d9d77]
C:\Windows\SysWOW64\ntdll.dll(RtlKnownExceptionFilter+0xb7) [0x776373e7]
-- Other runtime information
-----------------------------------------------
What's happening and how can I correct it?
--
Posted via http://www.ruby-forum.com/.