From a3d9672407b77c2a26af7e15a82d1f91e762b602 Mon Sep 17 00:00:00 2001 From: usa Date: Tue, 25 Dec 2012 10:14:12 +0000 Subject: [PATCH] * bignum.c, include/ruby/intern.h (rb_big_eql): exported. * thread.c (recursive_check): object_id maybe a Bignum, not Fixnum on LLP64. see also r38493 and r38548. reported by Heesob Park at [ruby-core:51083] [Bug #7607], and patched by shirosaki at [ruby-core:51095] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ bignum.c | 2 +- include/ruby/intern.h | 1 + thread.c | 17 ++++++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c2ad3a42f..e0b5e90bdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Dec 25 19:09:51 2012 NAKAMURA Usaku + + * bignum.c, include/ruby/intern.h (rb_big_eql): exported. + + * thread.c (recursive_check): object_id maybe a Bignum, not Fixnum on + LLP64. see also r38493 and r38548. + reported by Heesob Park at [ruby-core:51083] [Bug #7607], and patched + by shirosaki at [ruby-core:51095] + Tue Dec 25 18:53:35 2012 Koichi Sasada * vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): move diff --git a/bignum.c b/bignum.c index 376748513f..95a2504097 100644 --- a/bignum.c +++ b/bignum.c @@ -1710,7 +1710,7 @@ rb_big_eq(VALUE x, VALUE y) * 68719476736.eql?(68719476736.0) #=> false */ -static VALUE +VALUE rb_big_eql(VALUE x, VALUE y) { if (!RB_TYPE_P(y, T_BIGNUM)) return Qfalse; diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 6b8cfc1b31..5ff17a4971 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -124,6 +124,7 @@ VALUE rb_dbl2big(double); double rb_big2dbl(VALUE); VALUE rb_big_cmp(VALUE, VALUE); VALUE rb_big_eq(VALUE, VALUE); +VALUE rb_big_eql(VALUE, VALUE); VALUE rb_big_plus(VALUE, VALUE); VALUE rb_big_minus(VALUE, VALUE); VALUE rb_big_mul(VALUE, VALUE); diff --git a/thread.c b/thread.c index 4fabf8921c..602e7a3294 100644 --- a/thread.c +++ b/thread.c @@ -4599,7 +4599,7 @@ recursive_list_access(void) } /* - * Returns Qtrue iff obj_id (or the pair ) is already + * Returns Qtrue if obj_id (or the pair ) is already * in the recursion list. * Assumes the recursion list is valid. */ @@ -4607,17 +4607,24 @@ recursive_list_access(void) static VALUE recursive_check(VALUE list, VALUE obj_id, VALUE paired_obj_id) { +#if SIZEOF_LONG == SIZEOF_VOIDP + #define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other)) +#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP + #define OBJ_ID_EQL(obj_id, other) (RB_TYPE_P((obj_id), T_BIGNUM) ? \ + rb_big_eql((obj_id), (other)) : ((obj_id) == (other))) +#endif + VALUE pair_list = rb_hash_lookup2(list, obj_id, Qundef); if (pair_list == Qundef) return Qfalse; if (paired_obj_id) { if (!RB_TYPE_P(pair_list, T_HASH)) { - if (pair_list != paired_obj_id) - return Qfalse; + if (!OBJ_ID_EQL(paired_obj_id, pair_list)) + return Qfalse; } else { - if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id))) - return Qfalse; + if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id))) + return Qfalse; } } return Qtrue;