[#44578] Ruby初心者が作りました — Kabu and Ruby管理人 <kabu_and_ruby@...>

http://www.geocities.jp/kabuandruby/index.html

26 messages 2008/02/06

[#44691] ”Rubyアプリケーションプログラミング”の伝言サーバの使い方 — "Yangkook Kim" <yangkookkim@...>

キムと申します。オーム社から出版されている書籍、"Rubyアプリケーションプログラミング"のP267~275に掲載されている伝言サーバー&クライアントの利用の仕方がわかりません。質問を要約すると次の2点です。1、サーバーが正常に起動されているかどうかわからない。2、書き込みクライアントで入力をサーバーに送信する方法がわからない。

8 messages 2008/02/24

[ruby-list:44704] Ruby1.9.0でのインタプリタ組み込みについての質問

From: Masayuki Yamaguchi <Yamaguchi.Masayuki@...>
Date: 2008-02-27 11:06:09 UTC
List: ruby-list #44704
はじめまして、山口と申します。

Ruby1.9.0でのインタプリタ組み込みについての質問です。

スレッドを作成し、そこでインタプリタ初期化、rb_require("logger")を
実行すると、Segmentation fault が発生してしまうのですが、
何が原因でしょうか?

何か情報ありましたら、回答よろしくお願い致します。

# インタプリタ初期化はメインスレッド以外は不可
# configure のオプション指定が間違っている ..など


gcc :4.1.1 20070105 (Red Hat 4.1.1-51)
Ruby:1.9.0 (2007-12-25 revision 14709) [i686-linux]
configure:./configure --enable-shared

config.hで以下となっています。
#define STACK_END_ADDRESS __libc_stack_end

-- ソース -----------------------------------------------------
#include <ruby.h>
#include <pthread.h>

void *thread_func(void *arg)
{
    ruby_init();
    ruby_init_loadpath();
    ruby_script("sample");
    rb_require("logger");
}

int main()
{
    pthread_t thread;

    int status = pthread_create(&thread, NULL, thread_func, (void *)NULL);
    if(status != 0){
        return -1;
    }

    pthread_join(thread, NULL);
    ruby_finalize();

    return 0;
}


-- 実行結果 -----------------------------------------------------
/usr/local/lib/ruby/1.9.0/logger.rb:4: [BUG] Segmentation fault
ruby 1.9.0 (2007-12-25 revision 14709) [i686-linux]

-- control frame ----------
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :require
c:0003 p:0009 s:0006 b:0006 l:000d1c d:000d1c TOP    /usr/local/lib/ruby/1.9.0/logger.rb:4
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH :(null)
c:0001 p:0000 s:0002 b:0002 l:000001 d:000001 TOP    <dummy toplevel>:17
---------------------------
DBG> : "/usr/local/lib/ruby/1.9.0/logger.rb:4:in `<top (required)>'"
-- backtrace of native function call (Use addr2line) --
0x88a53c
0x7d233f
0x7d23b9
0x849916
0xdbb440
0x7e79c7
0x7e7ad7
0x7e8415
0x7e84e3
0x80d643
0x80f240
0x81a49d
0x822b9a
0x88cda3
0x80f69f
0x80f70a
0x848929
0x848c84
0x7dc224
0x7dc963
0x7dcb66
0x87f7ea
0x888b64
0x883e3c
0x887d99
0x8880f0
0x7dc273
0x7dc963
0x7dcb31
0x80488b5
0xb053db
0xa5f26e
--------------------------------------------------------
--
//山口政幸

In This Thread

Prev Next