Huge array allocation causes exit(1) in 64 bit environment

e$B1sF#$H?=$7$^$9!#e(B

64 bit e$B4D6-$GBg$-$J%a%b%j$r3NJ]$7$h$&$H$9$k$H!"%(%i!<I=<($b$J$/e(B
exit(1) e$B$9$k$h$&$G$9!#e(B

$ ./ruby -e ‘[1] * (2**32); p :foo’
$ echo $?
1

e$B$$$^$$$A2?$,5/$-$F$$$k$N$+$o$+$C$F$J$$$N$G$9$,!"e(B

  • rb_memerror e$B$Ge(B th->raised_flag |= RAISED_NOMEMORY e$B$9$ke(B
  • rb_longjmp e$B$Ge(B th->raised_flag & RAISED_EXCEPTION [email protected]$C$?$ie(B
    FATAL e$B$9$ke(B

e$B$H$$$&N.$l$G!"e(BRAISED_*
e$B$,0J2<$N$h$&$KDj5A$5$l$F$$$k$N$G$9$,!"e(B
e$B$3$l$O0U?^E*$J$b$N$G$7$g$&$+!#e(B

enum {
RAISED_EXCEPTION = 1,
RAISED_STACKOVERFLOW,
RAISED_NOMEMORY,
};

e$B%U%i%0MQES$J$i!“e(BRAISED_NOMEMORY e$B$Oe(B 4
e$B$J$N$+$J!”$H;W$$$^$7$?!#e(B

Index: eval_intern.h

— eval_intern.h (revision 16157)
+++ eval_intern.h (working copy)
@@ -194,8 +194,8 @@

enum {
RAISED_EXCEPTION = 1,

  • RAISED_STACKOVERFLOW,
  • RAISED_NOMEMORY,
  • RAISED_STACKOVERFLOW = 2,
  • RAISED_NOMEMORY = 4,
    };
    int rb_thread_set_raised(rb_thread_t *th);
    int rb_thread_reset_raised(rb_thread_t *th);

e$B$K$7$F$b!“e(BFATAL e$B$NI=<($,$J$$$N$OB>$K$b2?$+%P%0$,$”$k!)e(B

[email protected]$G$9!#e(B

At Tue, 22 Apr 2008 23:36:28 +0900,
Yusuke ENDOH wrote in [ruby-dev:34489]:

};

e$B%U%i%0MQES$J$i!“e(BRAISED_NOMEMORY e$B$Oe(B 4 e$B$J$N$+$J!”$H;W$$$^$7$?!#e(B

e$B$G$9$M!#e(BBit
Shifte$B$rF~$l$k$D$b$j$GK:$l$F$$$?$N$+$b!#$9$$$^$;$s!"e(B
e$BD>$7$F$*$$$F$/[email protected]$5$$!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs