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

ruby-changes:29547

From: shirosaki <ko1@a...>
Date: Mon, 24 Jun 2013 22:39:20 +0900 (JST)
Subject: [ruby-changes:29547] shirosaki:r41599 (trunk): dl/cfunc.c: fix conversion of Bignum

shirosaki	2013-06-24 22:39:08 +0900 (Mon, 24 Jun 2013)

  New Revision: 41599

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

  Log:
    dl/cfunc.c: fix conversion of Bignum
    
    * ext/dl/cfunc.c (rb_dlcfunc_call): fix conversion from Bignum to
      pointer. sizeof(DLSTACK_TYPE) is larger than sizeof(long) on
      Windows x64 and higher bits over sizeof(long) of DLSTACK_TYPE was
      zero even if a pointer value was over 32 bits which causes SEGV on
      DL::TestCPtr#test_to_ptr_io. Adding a cast solves the bug.

  Modified files:
    trunk/ChangeLog
    trunk/ext/dl/cfunc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41598)
+++ ChangeLog	(revision 41599)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jun 24 22:04:02 2013  Hiroshi Shirosaki  <h.shirosaki@g...>
+
+	* ext/dl/cfunc.c (rb_dlcfunc_call): fix conversion from Bignum to
+	  pointer. sizeof(DLSTACK_TYPE) is larger than sizeof(long) on
+	  Windows x64 and higher bits over sizeof(long) of DLSTACK_TYPE was
+	  zero even if a pointer value was over 32 bits which causes SEGV on
+	  DL::TestCPtr#test_to_ptr_io. Adding a cast solves the bug.
+
 Mon Jun 24 22:04:00 2013  Charlie Somerville  <charliesome@r...>
 
 	* eval_error.c (warn_printf): use rb_vsprintf instead so ruby specific
Index: ext/dl/cfunc.c
===================================================================
--- ext/dl/cfunc.c	(revision 41598)
+++ ext/dl/cfunc.c	(revision 41599)
@@ -372,7 +372,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) https://github.com/ruby/ruby/blob/trunk/ext/dl/cfunc.c#L372
             rb_big_pack(arg, ls, sizeof(ls)/sizeof(*ls));
             d = 0;
             for (j = 0; j < (int)(sizeof(ls)/sizeof(*ls)); j++)
-                d |= ls[j] << (j * sizeof(long) * CHAR_BIT);
+                d |= (DLSTACK_TYPE)ls[j] << (j * sizeof(long) * CHAR_BIT);
 	    stack[i] = d;
 	}
 	else {

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

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