Project

General

Profile

Actions

Bug #2258

closed

Kernel#require inside rb_require() inside rb_protect() inside SysV context fails

Added by sunaku (Suraj Kurapati) about 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
Backport:
[ruby-core:26244]

Description

=begin
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

~~~~> 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
=end

Files

extconf.rb (179 Bytes) extconf.rb sunaku (Suraj Kurapati), 10/23/2009 08:37 AM
hello.rb (212 Bytes) hello.rb sunaku (Suraj Kurapati), 10/23/2009 08:37 AM
main.c (2.78 KB) main.c sunaku (Suraj Kurapati), 10/23/2009 08:37 AM
extconf.rb (206 Bytes) extconf.rb updated to handle Ruby 1.8 sunaku (Suraj Kurapati), 10/23/2009 12:13 PM
main.c (2.95 KB) main.c updated to handle Ruby 1.8 and ucontext.h location sunaku (Suraj Kurapati), 10/23/2009 12:13 PM
ruby-ucontext.tgz (12.1 KB) ruby-ucontext.tgz tarball of ruby fully inside SysV context example sunaku (Suraj Kurapati), 10/23/2009 11:35 PM
ruby-ucontext-half.tgz (15.6 KB) ruby-ucontext-half.tgz example test case with ruby_init() in main() and rb_require() in SysV context sunaku (Suraj Kurapati), 10/24/2009 12:33 AM
ruby-ucontext-full.tgz (12.1 KB) ruby-ucontext-full.tgz example test case with both ruby_init() and rb_require() in SysV context sunaku (Suraj Kurapati), 10/24/2009 12:33 AM
ruby-ucontext-full.tgz (16.6 KB) ruby-ucontext-full.tgz increased SysV context stack size to 4 MiB sunaku (Suraj Kurapati), 10/24/2009 04:01 PM
0001-make-SET_STACK_END-macro-respect-rb_thread_t.machine.patch (2.31 KB) 0001-make-SET_STACK_END-macro-respect-rb_thread_t.machine.patch patch to make SET_STACK_END respect machine_stack_maxsize sunaku (Suraj Kurapati), 10/25/2009 03:40 AM
0001-add-ruby_bind_stack-to-inform-GC-about-explicit-stac.patch (1.84 KB) 0001-add-ruby_bind_stack-to-inform-GC-about-explicit-stac.patch good, minimal solution for this problem sunaku (Suraj Kurapati), 10/25/2009 01:28 PM
ruby-ucontext-full.tgz (9.88 KB) ruby-ucontext-full.tgz updated to do more complex Ruby things in hello.rb sunaku (Suraj Kurapati), 10/25/2009 01:28 PM
ruby-ucontext-static-stack.tgz (9.91 KB) ruby-ucontext-static-stack.tgz statically allocated stack sunaku (Suraj Kurapati), 10/25/2009 01:50 PM
ruby-ucontext-dynamic-stack.tgz (10.3 KB) ruby-ucontext-dynamic-stack.tgz dynamically allocated stack sunaku (Suraj Kurapati), 10/25/2009 01:50 PM
ruby-libpcl-dynamic-stack.tgz (10 KB) ruby-libpcl-dynamic-stack.tgz sunaku (Suraj Kurapati), 10/25/2009 03:19 PM
ruby-libpcl-static-stack.tgz (10.3 KB) ruby-libpcl-static-stack.tgz sunaku (Suraj Kurapati), 10/25/2009 03:19 PM
ruby-ucontext-dynamic-stack.tgz (10.2 KB) ruby-ucontext-dynamic-stack.tgz sunaku (Suraj Kurapati), 10/25/2009 03:19 PM
ruby-ucontext-static-stack.tgz (10 KB) ruby-ucontext-static-stack.tgz sunaku (Suraj Kurapati), 10/25/2009 03:19 PM
ruby_bind_stack.patch (2.67 KB) ruby_bind_stack.patch added changelog entry; fixed stack_start bug; renamed variables sunaku (Suraj Kurapati), 10/26/2009 03:31 AM
ruby_bind_stack.patch (2.67 KB) ruby_bind_stack.patch corrected ruby-core message ID to 26244 sunaku (Suraj Kurapati), 10/26/2009 03:49 AM
ruby_bind_stack.patch (2.66 KB) ruby_bind_stack.patch updated VALUE* to void* because value at memory address has no type sunaku (Suraj Kurapati), 10/27/2009 03:02 AM

Related issues 1 (1 open0 closed)

Has duplicate Ruby master - Feature #2294: [PATCH] ruby_bind_stack() to embed Ruby in coroutineAssignedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0