[前][次][番号順一覧][スレッド一覧]

ruby-changes:25793

From: kosaki <ko1@a...>
Date: Mon, 26 Nov 2012 16:00:14 +0900 (JST)
Subject: [ruby-changes:25793] kosaki:r37850 (trunk): * bignum.c (bigdivrem): restart calculation when bigdivrem1 was

kosaki	2012-11-26 16:00:04 +0900 (Mon, 26 Nov 2012)

  New Revision: 37850

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37850

  Log:
    * bignum.c (bigdivrem): restart calculation when bigdivrem1 was
      interrupted by signal. Otherwise, ruby script may see a garbage
      value.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37849)
+++ ChangeLog	(revision 37850)
@@ -1,3 +1,9 @@
+Mon Nov 26 15:50:29 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* bignum.c (bigdivrem): restart calculation when bigdivrem1 was
+	  interrupted by signal. Otherwise, ruby script may see a garbage
+	  value.
+
 Mon Nov 26 15:33:02 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* bignum.c (big_div_struct): added volatile to 'stop' member.
Index: bignum.c
===================================================================
--- bignum.c	(revision 37849)
+++ bignum.c	(revision 37850)
@@ -2713,16 +2713,22 @@
 }
 
 static VALUE
-bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
+bigdivrem(VALUE x, VALUE y_, volatile VALUE *divp, volatile VALUE *modp)
 {
+    VALUE y;
     struct big_div_struct bds;
-    long nx = RBIGNUM_LEN(x), ny = RBIGNUM_LEN(y);
+    long nx, ny;
     long i, j;
     VALUE z, yy, zz;
     BDIGIT *xds, *yds, *zds, *tds;
     BDIGIT_DBL t2;
     BDIGIT dd, q;
 
+  retry:
+    y = y_;
+    nx = RBIGNUM_LEN(x);
+    ny = RBIGNUM_LEN(y);
+
     if (BIGZEROP(y)) rb_num_zerodiv();
     xds = BDIGITS(x);
     yds = BDIGITS(y);
@@ -2795,6 +2801,11 @@
     bds.stop = Qfalse;
     if (nx > 10000 || ny > 10000) {
 	rb_thread_call_without_gvl(bigdivrem1, &bds, rb_big_stop, &bds);
+
+	if (bds.stop == Qtrue) {
+	    /* execute trap handler, but exception was not raised. */
+	    goto retry;
+	}
     }
     else {
 	bigdivrem1(&bds);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]