Decrease "stack level too deep" in Windows

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

Windowse$B$J%W%i%C%H%U%)!<%`$G!"<B:]$K;H$($k%9%?%C%/$r==J,;H$o$Je(B
e$B$$$&$A$Ke(Bstack level too deepe$B$K$J$C$F$7$^$&$H$$$&LdBj$,$"$C$?e(B
e$B$N$G$9$,!"2r7h$9$k%Q%C%A$r:n$C$F$_$^$7$?!#e(B

e$B$3$N%Q%C%A$rE,1~$9$kA0$G!“e(B
ruby -e “def hoge(n); p n; hoge(n + 1); end; hoge(0)”
e$B$H$$$&%o%s%i%$%J!<$G$Oe(B715e$BCJL$Ge(Bstack level topp
deepe$B$@$C$?$Ne(B
e$B$G$9$,!”$3$N%Q%C%AE,1~8e$Ge(B9193e$BCJ$^$G9T$1$k$h$&$K$J$j$^$9!#e(B

Windowse$B$K$7$+1F6A$J$$$O$:$J$s$G$9$,!"F~$l$F$b$$$$$G$7$g$&$+e(B?

Index: gc.c

RCS file: /home/cvs/ruby/gc.c,v
retrieving revision 1.243
diff -u -1 -p -r1.243 gc.c
— gc.c 7 Aug 2006 03:37:46 -0000 1.243
+++ gc.c 13 Sep 2006 15:14:51 -0000
@@ -472,3 +472,3 @@ unsigned int _stacksize = 262144;

undef HAVE_GETRLIMIT

-#elif defined(HAVE_GETRLIMIT)
+#elif defined(HAVE_GETRLIMIT) || defined(_WIN32)
static unsigned int STACK_LEVEL_MAX = 655300;
@@ -1540,2 +1540,15 @@ void ruby_init_stack(VALUE *addr
}
+#elif defined _WIN32

  • {
  • MEMORY_BASIC_INFORMATION mi;
  • DWORD size;
  • DWORD space;
  • if (VirtualQuery(&mi, &mi, sizeof(mi))) {
  •   size = (char *)mi.BaseAddress - (char *)mi.AllocationBase;
    
  •   space = size / 5;
    
  •   if (space > 1024*1024) space = 1024*1024;
    
  •   STACK_LEVEL_MAX = (size - space) / sizeof(VALUE);
    
  • }
  • }
    #endif

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

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29569] decrease “stack level too deep” in
Windows”
on Thu, 14 Sep 2006 00:20:05 +0900, “U.Nakamura”
[email protected] writes:

|Windowse$B$J%W%i%C%H%U%)!<%`$G!“<B:]$K;H$($k%9%?%C%/$r==J,;H$o$Je(B
|e$B$$$&$A$Ke(Bstack level too deepe$B$K$J$C$F$7$^$&$H$$$&LdBj$,$”$C$?e(B
|e$B$N$G$9$,!"2r7h$9$k%Q%C%A$r:n$C$F$_$^$7$?!#e(B

|Windowse$B$K$7$+1F6A$J$$$O$:$J$s$G$9$,!"F~$l$F$b$$$$$G$7$g$&$+e(B?

e$B$I$&$>!#e(B