Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Embedded Ruby 1.8.7—Segmentation fault

Reply
Thread Tools

Embedded Ruby 1.8.7—Segmentation fault

 
 
Slava Shynkarenko
Guest
Posts: n/a
 
      08-16-2010
Dear community,
I would appreciate if you could help me to solve this. I’m experimenting
with Ruby 1.8.7 embedding. Ruby has been built from sources under
Windows by VisualStudio 2008 compiler, with no errors.

Here is my C++ code:

void main()
{
__try
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();

ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/site_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/1.8/i386-mswin32_90" );

ruby_script( "embedded" );
rb_load_file( "test.rb" );
ruby_run();
}
__finally
{
ruby_finalize();
}
}


Please note, it’s only an experiment, so please don’t pay much attention
on irrelevant mistakes.

This is my test.rb:

print "\n=== RUBY ===\n"

print "Hello World!"*3;

print "\n\nLoad:\n"
print $LOAD_PATH
print "\n"

require '1'
m = My.new
m.hello

print "\n=== GETTING LOCALHOST... ===\n"
require 'socket'

host = 'localhost'
port = 80
path = "/"

request = "GET #{path} HTTP/1.0\r\n\r\n"

socket = TCPSocket.open( host, port )
socket.print( request )
response = socket.read

headers, body = response.split( "\r\n\r\n", 2 )

print body



And that is 1.rb, which is located near test.rb:

class My
def hello
print "Hello from class My";
end
end


The socket code actually produces segmentation fault. More precisely
it’s the “require” statement. So everything works well except the socket
part. And by commenting out all the socket-relevant code, I’ve learned
that exactly the “require” statement causes the issue.

Note, everything works great when I run the script by ruby.exe, compiled
myself!

Please help me to proceed.
Thank you.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Slava Shynkarenko
Guest
Posts: n/a
 
      08-16-2010
I’m sorry, I forgot to include the output:

C:\Users\Slava\Documents\Developments\ruby1.8.7_em bedded\Debug>ruby1.8.7_embedded.exe

=== RUBY ===
Hello World!Hello World!Hello World!

Load:
C:/Users/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib/ruby/site_ruby/1.8C:/Users/Slava/Documents/Developments/ruby1.8.7_em
bedded/Debug/lib/ruby/site_ruby/1.8/i386-msvcr90C:/Users/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib/ruby/site_rubyC:/Use
rs/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib/ruby/vendor_ruby/1.8C:/Users/Slava/Documents/Developments/ruby1.8.7_embedd
ed/Debug/lib/ruby/vendor_ruby/1.8/i386-msvcr90C:/Users/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib/ruby/vendor_rubyC:/Use
rs/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib/ruby/1.8C:/Users/Slava/Documents/Developments/ruby1.8.7_embedded/Debug/lib
/ruby/1.8/i386-mswin32_90.C:/ruby1.8.7/lib/ruby/site_ruby/1.8C:/ruby1.8.7/lib/ruby/site_ruby/1.8/i386-msvcr90C:/ruby1.8.7/lib/ruby/site
_rubyC:/ruby1.8.7/lib/ruby/vendor_ruby/1.8C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8/i386-msvcr90C:/ruby1.8.7/lib/ruby/vendor_rubyC:/ruby1.8
7/lib/ruby/1.8C:/ruby1.8.7/lib/ruby/1.8/i386-mswin32_90
Hello from class My
=== GETTING LOCALHOST... ===
C:/ruby1.8.7/lib/ruby/1.8/i386-mswin32_90/socket.so: [BUG] Segmentation
fault
ruby 1.8.7 (2010-07-17 patchlevel 300) [i386-mswin32_90]


This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Databind an embedded control in an embedded datagrid Thomas Dodds ASP .Net Datagrid Control 0 07-26-2004 08:20 PM
Stack fault and page fault help S.Flournoy Computer Support 2 04-17-2004 04:23 PM
Asterisk and fault tolerance & embedded solutions. Charles Hizark VOIP 1 03-05-2004 09:38 AM



Advertisments