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

ruby-changes:45082

From: nobu <ko1@a...>
Date: Fri, 23 Dec 2016 07:34:22 +0900 (JST)
Subject: [ruby-changes:45082] nobu:r57155 (trunk): time.c: inquire suspicious values

nobu	2016-12-23 07:34:18 +0900 (Fri, 23 Dec 2016)

  New Revision: 57155

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57155

  Log:
    time.c: inquire suspicious values

  Modified files:
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 57154)
+++ time.c	(revision 57155)
@@ -53,6 +53,30 @@ eq(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/time.c#L53
     return RTEST(rb_funcall(x, id_eq, 1, y));
 }
 
+#ifdef _MSC_VER
+static VALUE
+inquire_value(VALUE x, const char *mesg)
+{
+    VALUE klass;
+    LPEXCEPTION_POINTERS info;
+    if (SPECIAL_CONST_P(x)) return Qnil;
+    __try {
+	klass = CLASS_OF(x);
+    }
+    __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
+	      (info = GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER) :
+	      EXCEPTION_CONTINUE_SEARCH) {
+	PEXCEPTION_RECORD rec = info->ExceptionRecord;
+	rb_fatal("Access violation at %p: class of %p: %s",
+		 (void *)rec->ExceptionInformation[1],
+		 (void *)x, mesg);
+    }
+    return klass;
+}
+#else
+# define inquire_value(x, mesg) (void)(x)
+#endif
+
 static int
 cmp(VALUE x, VALUE y)
 {
@@ -63,11 +87,8 @@ cmp(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/time.c#L87
             return 1;
         return 0;
     }
-#ifdef _WIN32
-    if (rb_objspace_garbage_object_p(x)) {
-	rb_fatal("cmp(%p, %p)", (void *)x, (void *)y);
-    }
-#endif
+    inquire_value(x, "cmp(x)");
+    inquire_value(y, "cmp(y)");
     return rb_cmpint(rb_funcall(x, id_cmp, 1, y), x, y);
 }
 

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

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