From: Suraj Kurapati Date: 2009-10-23T08:37:40+09:00 Subject: [ruby-core:26244] [Bug #2258] Kernel#require inside rb_require() inside rb_protect() inside SysV context fails Bug #2258: Kernel#require inside rb_require() inside rb_protect() inside SysV context fails http://redmine.ruby-lang.org/issues/show/2258 Author: Suraj Kurapati Status: Open, Priority: Normal Category: ext ruby -v: ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] Hi, I get the following error when I call Kernel#require() inside a Ruby script that is being run by rb_require(), which itself is running inside rb_protect(), which in turn is running inside a UNIX System V context. "[BUG] object allocation during garbage collection phase" An example test case to reproduce this bug is attached, and the result of running this test case is shown below. Note that this test case runs correctly without any errors if you remove the call to Kernel#require in "hello.rb" line 7. Thanks for your consideration. ############################################################### # ruby -v extconf.rb && sed -i 's,-shared,,g' Makefile ############################################################### ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] checking for ruby_init() in -lruby-static... yes checking for sys/ucontext.h... yes creating Makefile ############################################################### # make && ./main.so ############################################################### gcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_SYS_UCONTEXT_H -D_FILE_OFFSET_BITS=64 -fPIC -march=i686 -mtune=generic -O2 -pipe -O2 -g -Wall -Wno-parentheses -fPIC -o main.o -c main.c main.c: In function ���relay_from_main_to_ruby���: main.c:15: warning: implicit declaration of function ���swapcontext��� main.c: In function ���main���: main.c:99: warning: implicit declaration of function ���getcontext��� main.c:100: warning: implicit declaration of function ���makecontext��� gcc -o main.so main.o -L. -L/usr/lib -Wl,-R/usr/lib -L. -Wl,--hash-style=gnu -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,-R -Wl,/usr/lib -L/usr/lib -lruby -lruby-static -lpthread -lrt -ldl -lcrypt -lm -lc Main: relay_from_main_to_ruby() begin Ruby: context begin Ruby: relay 0 Ruby: relay_from_ruby_to_main() begin Main: relay_from_main_to_ruby() end Main: relay_from_main_to_ruby() begin Ruby: relay_from_ruby_to_main() end Ruby: relay 1 Ruby: relay_from_ruby_to_main() begin Main: relay_from_main_to_ruby() end Main: relay_from_main_to_ruby() begin Ruby: relay_from_ruby_to_main() end Ruby: relay 2 Ruby: relay_from_ruby_to_main() begin Main: relay_from_main_to_ruby() end Main: relay_from_main_to_ruby() begin Ruby: relay_from_ruby_to_main() end Ruby: require 'hello' begin ~~~~> Hello World! The time is 2009-10-22 16:36:06 -0700. ~~~~> Doing relay from /home/sun/lab/ruby-ucontext/hello.rb:3 Ruby: relay_from_ruby_to_main() begin Main: relay_from_main_to_ruby() end Main: relay_from_main_to_ruby() begin Ruby: relay_from_ruby_to_main() end ~~~~> OMG, back from main!! :-) /home/sun/lab/ruby-ucontext/hello.rb:7: [BUG] Segmentation fault ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] -- control frame ---------- c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require c:0003 p:0080 s:0006 b:0006 l:000005 d:000005 TOP /home/sun/lab/ruby-ucontext/hello.rb:7 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:001cac d:001cac TOP --------------------------- /home/sun/lab/ruby-ucontext/hello.rb:7: [BUG] object allocation during garbage collection phase ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux] -- control frame ---------- c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require c:0003 p:0080 s:0006 b:0006 l:000005 d:000005 TOP /home/sun/lab/ruby-ucontext/hello.rb:7 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:001cac d:001cac TOP --------------------------- Segmentation fault ---------------------------------------- http://redmine.ruby-lang.org