Error: Ruby 1.8.7 object allocation during garbage collection phase

森脇です。

Debianでrubyã‚’ãƒ‘ãƒƒã‚±ãƒ¼ã‚¸åŒ–ã—ã¦ãŠã‚Šã¾ã™ã€‚ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã‚¨ãƒ©ãƒ¼å ±å‘ŠãŒã‚ã‚Šã¾ã—ãŸã®ã§ã€ãŠ
尋ねします。

LibXml[1]を次のように使うと、
[BUG] object allocation during garbage collection phase
というエラーでクラッシュします。LibXmlの問題なのかもしれませんが、メッセージから
するとRubyの問題のように見えるのですが、いかがでしょうか。Ruby 1.8.6では問題な
かったのですが、1.8.7にアップグレードするとエラーとなります。

環境:
ruby 1.8.7 (2008-05-31 patchlevel 0) [i486-linux]
LibXml 0.5.2.0

[1] http://libxml.rubyforge.org/

===== reproducible =====

require ‘xml/libxml’

i = 0
while true
XML::Document.new
i += 1
puts “***************** #{i} *********” if i%100 == 0
end

===========================

stack trace

(snip)
***************** 206300 *********
***************** 206400 *********
***************** 206500 *********
***************** 206600 *********
./libxml-ruby-bug.rb:7: [BUG] object allocation during garbage
collection phase
ruby 1.8.7 (2008-05-31 patchlevel 0) [i486-linux]

Program received signal SIGABRT, Aborted.
[Switching to Thread 0xb7d1ab60 (LWP 29312)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0 0xffffe410 in __kernel_vsyscall ()
#1 0xb7d45ef5 in raise () from /lib/i686/cmov/libc.so.6
#2 0xb7d47871 in abort () from /lib/i686/cmov/libc.so.6
#3 0xb7f0671b in rb_bug (
fmt=0xb7f9409c “object allocation during garbage collection phase”)
at
error.c:213
#4 0xb7f2a2f5 in rb_newobj () at gc.c:422
#5 0xb7f2a322 in rb_data_object_alloc (klass=3083878900,
datap=0x807eb70,
dmark=0xb7ce2a60 <ruby_xml_state_mark>, dfree=0xb7ce2d40
<ruby_xml_state_free>)
at gc.c:443
#6 0xb7ce2cba in ruby_xml_state_object ()
from /usr/lib/ruby/1.8/i486-linux/xml/libxml_so.so
#7 0xb7ce2d27 in ruby_xml_state_marker ()
from /usr/lib/ruby/1.8/i486-linux/xml/libxml_so.so
#8 0xb7cd6d47 in ruby_xml_document_mark ()
from /usr/lib/ruby/1.8/i486-linux/xml/libxml_so.so
#9 0xb7f29342 in gc_mark_children (ptr=3083763108, lev=1) at gc.c:988
#10 0xb7f29011 in mark_locations_array (x=0xbfcf7960, n=1584) at
gc.c:672
#11 0xb7f2982e in garbage_collect () at gc.c:1408
#12 0xb7f2a2e5 in rb_newobj () at gc.c:424
#13 0xb7f7c877 in str_alloc (klass=3083953160) at string.c:67
#14 0xb7f7c8fc in str_new (klass=0, ptr=0xbfcf70c5 “206700”, len=6) at
string.c:89
#15 0xb7f7d552 in rb_str_new2 (ptr=0xbfcf70c5 “206700”) at string.c:115
#16 0xb7f3ebcd in rb_fix2str (x=413401, base=10) at numeric.c:2029
#17 0xb7f41097 in fix_to_s (argc=0, argv=0x0, x=413401) at
numeric.c:2060
#18 0xb7f09c90 in call_cfunc (func=0xb7f41040 <fix_to_s>, recv=413401,
len=6,
argc=0,
argv=0x7280) at eval.c:5743
#19 0xb7f14ffc in rb_call0 (klass=3083942520, recv=413401, id=3137,
oid=3137,
argc=0,
argv=0x0, body=0xb7d13a00, flags=0) at eval.c:5899
#20 0xb7f15190 in rb_call (klass=3083942520, recv=413401, mid=3137,
argc=0,
argv=0x0,
scope=1, self=6) at eval.c:6146
#21 0xb7f15f34 in vafuncall (recv=413401, mid=3137, n=0, ar=0xbfcf7464)
at
eval.c:6223
#22 0xb7f160a4 in rb_funcall (recv=413401, mid=3137, n=0) at eval.c:6240
#23 0xb7f812da in rb_obj_as_string (obj=413401) at string.c:309
#24 0xb7f111cd in rb_eval (self=3083958620, n=) at
eval.c:3858
#25 0xb7f1134b in rb_eval (self=3083958620, n=) at
eval.c:3878
#26 0xb7f120c6 in rb_eval (self=3083958620, n=) at
eval.c:3502
#27 0xb7f12263 in rb_eval (self=3083958620, n=) at
eval.c:3146
#28 0xb7f21577 in ruby_exec_internal () at eval.c:1642
#29 0xb7f215c2 in ruby_exec () at eval.c:1662
#30 0xb7f215ff in ruby_run () at eval.c:1672
#31 0x080486ed in main (argc=Cannot access memory at address 0x7280
) at main.c:48

では。

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:35156] error: Ruby 1.8.7 object allocation during
garbage collection phase”
on Jun.18,2008 22:26:41, [email protected] wrote:

LibXml[1]e$B$r<!$N$h$&$K;H$&$H!“e(B
[BUG] object allocation during garbage collection phase
e$B$H$$$&%(%i!<$G%/%i%C%7%e$7$^$9!#e(BLibXmle$B$NLdBj$J$N$+$b$7$l$^$;$s$,!”%a%C%;!<%8$+$ie(B
e$B$9$k$He(BRubye$B$NLdBj$N$h$&$K8+$($k$N$G$9$,!"$$$+$,$G$7$g$&$+!#e(BRuby 1.8.6e$B$G$OLdBj$Je(B
e$B$+$C$?$N$G$9$,!“e(B1.8.7e$B$K%”%C%W%0%l!<%I$9$k$H%(%i!<$H$J$j$^$9!#e(B

e$B%a%C%;!<%8$NDL$j!“e(BGCe$BCf$Ke(Brubye$B%*%V%8%’%/%H$N%”%m%1!<%7%g%s$r9Te(B
e$B$C$F$$$^$9!#e(B
LibXmle$B$NLdBj$G$9!#e(B

e$B%=!<%98+$^$7$?$1$I!"$J$s$H$$$&$+!"$3$&e(B…

1.8.6e$B0JA0$G$O$=$N%A%’%C%/$,$J$+$C$?$N$G!"$J$s$H$J$/1?$h$/F0$$e(B
e$B$?$j$9$k$3$H$b$"$C$?$h$&$G$9$,!"$A$g$C$H1?$,0-$$$He(BSEGVe$B$,5/$-e(B
e$B$k$O$:$G$9!#e(B
e$B$H$$$&$o$1$G!"e(B1.8.6e$B$b:G6a$=$N%A%’%C%/$,F~$C$FF1$8$h$&$K$3$&$7e(B
e$B$?LdBj$r8!=P$7$Fe(B[BUG]e$B$r=P$9$h$&$K$J$C$?$=$&$G$9!#e(B

e$B$=$l$G$O!#e(B