Issue #6344 has been updated by kosaki (Motohiro KOSAKI).


If increasing machine stack, it definitly reduce limit of number of fibers.
But, of course, RISC need more stack than CISC and 64bit need more stack than 32bit. then I'm not surprised this patch solved
ppc issue. So, I suspect the best way is,

#if 64BIT
#define FIBER_MACHINE_STACK_ALLOCATION_SIZE  (0x20000)
#else	
#define FIBER_MACHINE_STACK_ALLOCATION_SIZE  (0x10000)
#endif

or likewise. I don't think dynamic fiber stack feature fit 1.9.3 branch.



----------------------------------------
Bug #6344: 1.9.3 p125, p194 ruby causes SEGV with test_massign.rb on ppc/ppc64
https://bugs.ruby-lang.org/issues/6344#change-26124

Author: mtasaka (Mamoru Tasaka)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: 
Target version: 1.9.3
ruby -v: ruby1.9.3p125


1.9.3 p125, p194 ruby causes SEGV with test_massign.rb on ppc/ppc64.
Short reproducer and backtrace with ruby 1.9.3 p125:



[tasaka@localhost ruby-1.9.3-p125]$ cat rubydev-32581.rb 
  a,s=[],"aaa"
  300.times { a<<s; s=s.succ }
  eval <<-END__
  GC.stress=true
  Fiber.new do
    #{ a.join(",") },*zzz=1
  end.resume
  END__
[tasaka@localhost ruby-1.9.3-p125]$ gdb ./miniruby
...
...
This GDB was configured as "ppc64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from
/home/tasaka/rpmbuild/BUILD/ruby-1.9.3-p125/miniruby...done.
(gdb) run  -Ilib -I. --disable-gems ./rubydev-32581.rb 
Starting program: /home/tasaka/rpmbuild/BUILD/ruby-1.9.3-p125/miniruby -Ilib
-I. --disable-gems ./rubydev-32581.rb
[Thread debugging using libthread_db enabled]
[New Thread 0xfffb1dff200 (LWP 1759)]

Program received signal SIGSEGV, Segmentation fault.
0x00000080db556b20 in .__makecontext () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install
nss-softokn-freebl-3.12.9-3.el7.ppc64
(gdb) thread apply all bt

Thread 2 (Thread 0xfffb1dff200 (LWP 1759)):
#0  0x00000080db5fe054 in .__select () from /lib64/libc.so.6
#1  0x000000001018911c in thread_timer (p=0x10280f68) at thread_pthread.c:1155
#2  0x00000080db70b330 in start_thread (arg=0xfffb1dff200) at
pthread_create.c:299
#3  0x00000080db6076ec in .__clone () from /lib64/libc.so.6

Thread 1 (Thread 0x80db4d7010 (LWP 1756)):
#0  0x00000080db556b20 in .__makecontext () from /lib64/libc.so.6
#1  0x000000001018ff80 in fiber_initialize_machine_stack_context
(fib=0x103ab970, size=65536) at cont.c:606
#2  0x0000000010190094 in fiber_setcontext (newfib=0x103ab970,
oldfib=0x103ac940) at cont.c:623
#3  0x0000000010190214 in fiber_store (next_fib=0x103ab970) at cont.c:1234
#4  0x00000000101903f8 in fiber_switch (fibval=271105960, argc=<value optimized
out>, argv=0xfffb1e00098) at cont.c:1319
#5  rb_fiber_resume (fibval=271105960, argc=<value optimized out>,
argv=0xfffb1e00098) at cont.c:1347
#6  0x00000000101905e4 in rb_fiber_m_resume (argc=<value optimized out>,
argv=<value optimized out>, fib=<value optimized out>) at cont.c:1404
#7  0x000000001016c754 in call_cfunc (func=@0x10255a90: 0x101905c0
<rb_fiber_m_resume>, recv=271105960, len=<value optimized out>, argc=<value
optimized out>, 
    argv=<value optimized out>) at vm_insnhelper.c:326
#8  0x0000000010171c74 in vm_call_cfunc (th=0x10281560, cfp=0xfffb1effe00,
num=<value optimized out>, blockptr=<value optimized out>, flag=0, 
    id=<value optimized out>, me=0x1039b8f0, recv=271105960) at
vm_insnhelper.c:404
#9  vm_call_method (th=0x10281560, cfp=0xfffb1effe00, num=<value optimized
out>, blockptr=<value optimized out>, flag=0, id=<value optimized out>,
me=0x1039b8f0, 
    recv=271105960) at vm_insnhelper.c:534
#10 0x00000000101734f4 in vm_exec_core (th=0x10281560, initial=<value optimized
out>) at insns.def:1015
#11 0x0000000010178da8 in vm_exec (th=0x10281560) at vm.c:1220
#12 0x0000000010179480 in eval_string_with_cref (self=271477440, src=271373360,
scope=4, cref=0x0, file=0x101b7fd8 "(eval)", line=1) at vm_eval.c:1050
#13 0x0000000010179b20 in eval_string (argc=<value optimized out>, argv=<value
optimized out>, self=271477440) at vm_eval.c:1091
#14 rb_f_eval (argc=<value optimized out>, argv=<value optimized out>,
self=271477440) at vm_eval.c:1139
#15 0x000000001016c754 in call_cfunc (func=@0x10254660: 0x101799a0 <rb_f_eval>,
recv=271477440, len=<value optimized out>, argc=<value optimized out>, 
    argv=<value optimized out>) at vm_insnhelper.c:326
#16 0x0000000010171c74 in vm_call_cfunc (th=0x10281560, cfp=0xfffb1efff08,
num=<value optimized out>, blockptr=<value optimized out>, flag=8, 
    id=<value optimized out>, me=0x1030f710, recv=271477440) at
vm_insnhelper.c:404
#17 vm_call_method (th=0x10281560, cfp=0xfffb1efff08, num=<value optimized
out>, blockptr=<value optimized out>, flag=8, id=<value optimized out>,
me=0x1030f710, 
    recv=271477440) at vm_insnhelper.c:534
#18 0x00000000101734f4 in vm_exec_core (th=0x10281560, initial=<value optimized
out>) at insns.def:1015
#19 0x0000000010178da8 in vm_exec (th=0x10281560) at vm.c:1220
#20 0x0000000010179078 in rb_iseq_eval_main (iseqval=271386440) at vm.c:1461
#21 0x00000000100559a8 in ruby_exec_internal (n=0x102d0748) at eval.c:204
#22 0x00000000100559f8 in ruby_exec_node (n=value has been optimized out
) at eval.c:251
#23 0x0000000010057650 in ruby_run_node (n=0x102d0748) at eval.c:244
#24 0x0000000010015664 in main (argc=5, argv=0xffffffff528) at main.c:38

1.9.3 p194 causes the same segv.

The attached patch seems to suppress this segv.


-- 
http://bugs.ruby-lang.org/