H
Hannes Wyss
Hello Rubyists!
let me apologize first: I have no means of condensing my problem to a few
lines of code. I'll explain:
I'm currently building and maintaining a Pharmaceutical Database
(http://www.oddb.org) that has meanwhile grown to 1.5GB in RAM.
Persistence is achieved using the excellent Madeleine Package. One
required Module within the application is Rwv2, a self-knitted Wrapper to
the wv2 (MS-Word viewer) library. (Available at the RAA or directly at
download.ywesee.com/ruby/rwv2)
The application only Segfaults if
- The Full Database is Memory-Resident - && Rwv2 is loaded (but none of
its Classes instantiated)
oddb> ObjectSpace.each_object(Rwv2:arser) {} -> 0
- && Marshal.dump(@system)is called
- && $ ruby --version
ruby 1.8.0 (2003-08-10) [i386-linux]
(no other version tested)
It seems that GC reaches the Stack-Limit (but then why don't I get "stack
level too deep" ?):
(gdb) bt -10
Previous frame inner to this frame (corrupt stack?) (gdb) bt -10
#25734 0x4005012b in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#25735 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#25736 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#25737 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#25738 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#25739 0x4004fdf2 in rb_source_filename () from /usr/lib/libruby1.8.so.1.8
#25740 0x40046be9 in rb_set_safe_level () from /usr/lib/libruby1.8.so.1.8
#25741 0x00001056 in ?? ()
#25742 0xbff856c8 in ?? ()
#25743 0x4004feb8 in rb_mark_hash () from /usr/lib/libruby1.8.so.1.8 (gdb)
bt 10
#0 0x4004fff9 in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#1 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#2 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#3 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#4 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#5 0x40050112 in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#6 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#7 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#8 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#9 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
If I understand Ruby-Extensions correctly, the only function called in
Rwv2 so far should be Init_rwv2()- so the only Objects to be marked should
be the Module and its Classes and Constants:
<<-EOS
#include "ruby.h"
<SNIPPAGE>
extern "C" {
VALUE mRwv2;
VALUE cRwv2Parser;
<MORE SNIPPAGE>
void Init_rwv2() {
/* module Rwv2 */
mRwv2 = rb_define_module("Rwv2");
rb_define_module_function(mRwv2, "create_parser",
(VALUE (*)(...))rwv2_create_parser, 1);
<YET MORE SNIPPAGE>
rb_define_const(mRwv2, "HEADER_EVEN", INT2FIX(0x01));
rb_define_const(mRwv2, "HEADER_ODD", INT2FIX(0x02));
<ALWAYS SNIPPING SIMILAR STUFF, NOTHING NEW>
/* class Rwv2:arser */
cRwv2Parser = rb_define_class_under(mRwv2, "Parser", rb_cObject);
rb_define_method(cRwv2Parser, "is_ok?",
(VALUE (*)(...)) rwv2_parser_is_ok, 0);
rb_define_method(cRwv2Parser, "parse",
(VALUE (*)(...)) rwv2_parser_parse, 0);
rb_define_method(cRwv2Parser, "set_inline_replacement_handler",
(VALUE (*)(...))
rwv2_parser_set_inline_replacement_handler, 1);
<MUCH SNIPPAGE>
} // extern "C"
EOS
(full source at:
http://download.ywesee.com/ruby/rwv2/rwv2-0.5.0/ext/rwv2/rwv2.cpp)
I'm pretty sure the problem must lie in my wrapper code, as I'm not
exactly fluent in C++, but it definitely looks as if I'm stuck. What
should my next steps be? Can I get any of you Ruby-Gods more Information?
Thanks in advance!
Hannes
let me apologize first: I have no means of condensing my problem to a few
lines of code. I'll explain:
I'm currently building and maintaining a Pharmaceutical Database
(http://www.oddb.org) that has meanwhile grown to 1.5GB in RAM.
Persistence is achieved using the excellent Madeleine Package. One
required Module within the application is Rwv2, a self-knitted Wrapper to
the wv2 (MS-Word viewer) library. (Available at the RAA or directly at
download.ywesee.com/ruby/rwv2)
The application only Segfaults if
- The Full Database is Memory-Resident - && Rwv2 is loaded (but none of
its Classes instantiated)
oddb> ObjectSpace.each_object(Rwv2:arser) {} -> 0
- && Marshal.dump(@system)is called
- && $ ruby --version
ruby 1.8.0 (2003-08-10) [i386-linux]
(no other version tested)
It seems that GC reaches the Stack-Limit (but then why don't I get "stack
level too deep" ?):
(gdb) bt -10
Previous frame inner to this frame (corrupt stack?) (gdb) bt -10
#25734 0x4005012b in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#25735 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#25736 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#25737 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#25738 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#25739 0x4004fdf2 in rb_source_filename () from /usr/lib/libruby1.8.so.1.8
#25740 0x40046be9 in rb_set_safe_level () from /usr/lib/libruby1.8.so.1.8
#25741 0x00001056 in ?? ()
#25742 0xbff856c8 in ?? ()
#25743 0x4004feb8 in rb_mark_hash () from /usr/lib/libruby1.8.so.1.8 (gdb)
bt 10
#0 0x4004fff9 in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#1 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#2 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#3 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#4 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#5 0x40050112 in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
#6 0x4004fe2b in rb_gc_mark_locations () from /usr/lib/libruby1.8.so.1.8
#7 0x4008cda9 in st_foreach () from /usr/lib/libruby1.8.so.1.8
#8 0x4004fe5c in rb_mark_tbl () from /usr/lib/libruby1.8.so.1.8
#9 0x400500bf in rb_gc_mark () from /usr/lib/libruby1.8.so.1.8
If I understand Ruby-Extensions correctly, the only function called in
Rwv2 so far should be Init_rwv2()- so the only Objects to be marked should
be the Module and its Classes and Constants:
<<-EOS
#include "ruby.h"
<SNIPPAGE>
extern "C" {
VALUE mRwv2;
VALUE cRwv2Parser;
<MORE SNIPPAGE>
void Init_rwv2() {
/* module Rwv2 */
mRwv2 = rb_define_module("Rwv2");
rb_define_module_function(mRwv2, "create_parser",
(VALUE (*)(...))rwv2_create_parser, 1);
<YET MORE SNIPPAGE>
rb_define_const(mRwv2, "HEADER_EVEN", INT2FIX(0x01));
rb_define_const(mRwv2, "HEADER_ODD", INT2FIX(0x02));
<ALWAYS SNIPPING SIMILAR STUFF, NOTHING NEW>
/* class Rwv2:arser */
cRwv2Parser = rb_define_class_under(mRwv2, "Parser", rb_cObject);
rb_define_method(cRwv2Parser, "is_ok?",
(VALUE (*)(...)) rwv2_parser_is_ok, 0);
rb_define_method(cRwv2Parser, "parse",
(VALUE (*)(...)) rwv2_parser_parse, 0);
rb_define_method(cRwv2Parser, "set_inline_replacement_handler",
(VALUE (*)(...))
rwv2_parser_set_inline_replacement_handler, 1);
<MUCH SNIPPAGE>
} // extern "C"
EOS
(full source at:
http://download.ywesee.com/ruby/rwv2/rwv2-0.5.0/ext/rwv2/rwv2.cpp)
I'm pretty sure the problem must lie in my wrapper code, as I'm not
exactly fluent in C++, but it definitely looks as if I'm stuck. What
should my next steps be? Can I get any of you Ruby-Gods more Information?
Thanks in advance!
Hannes