From e75c34c2e9f9e1c629cdab13c0c400494f49adb7 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 20 Oct 2003 02:06:42 +0000 Subject: [PATCH] * gc.c (gc_sweep): loosen page free condition to avoid add_heap() race condition. [ruby-dev:21633] * gc.c (gc_sweep): do not update malloc_limit when malloc_increase is smaller than malloc_limit. * ext/socket/socket.c (make_hostent): h_aliases may be NULL. (ruby-bugs PR#1195) * ext/socket/socket.c (sock_s_gethostbyaddr): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 ++++++++++++++++- ext/socket/socket.c | 12 ++++++++---- gc.c | 8 +++++--- marshal.c | 26 +++++++++++++------------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index be4ee182ff..e5d56c3954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Oct 20 11:00:46 2003 Yukihiro Matsumoto + + * gc.c (gc_sweep): loosen page free condition to avoid add_heap() + race condition. [ruby-dev:21633] + + * gc.c (gc_sweep): do not update malloc_limit when malloc_increase + is smaller than malloc_limit. + Mon Oct 20 09:45:12 2003 NAKAMURA Usaku * lib/debug.rb (debug_command): remove debug print. @@ -53,10 +61,17 @@ Fri Oct 17 11:15:22 2003 NAKAMURA Usaku * MANIFEST: add test/ruby/test_range.rb. +Fri Oct 17 03:21:23 2003 William Sobel + + * ext/socket/socket.c (make_hostent): h_aliases may be NULL. + (ruby-bugs PR#1195) + + * ext/socket/socket.c (sock_s_gethostbyaddr): ditto. + Fri Oct 17 00:12:41 2003 Hidetoshi NAGAI * ext/tk/lib/tk.rb: (bug fix) instance variable @frame was used - without initializing on TkComposite module + without initializing on TkComposite module. Thu Oct 16 23:51:04 2003 Hidetoshi NAGAI diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 95ec45bfe6..aa568cf6b3 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -1046,8 +1046,10 @@ make_hostent(addr, ipaddr) #else h = gethostbyname(addr->ai_canonname); #endif - for (pch = h->h_aliases; *pch; pch++) { - rb_ary_push(names, rb_str_new2(*pch)); + if (h->h_aliases != NULL) { + for (pch = h->h_aliases; *pch; pch++) { + rb_ary_push(names, rb_str_new2(*pch)); + } } #if defined(HAVE_GETIPNODEBYNAME) freehostent(h); @@ -2022,8 +2024,10 @@ sock_s_gethostbyaddr(argc, argv) rb_ary_push(ary, rb_str_new2(h->h_name)); names = rb_ary_new(); rb_ary_push(ary, names); - for (pch = h->h_aliases; *pch; pch++) { - rb_ary_push(names, rb_str_new2(*pch)); + if (h->h_aliases != NULL) { + for (pch = h->h_aliases; *pch; pch++) { + rb_ary_push(names, rb_str_new2(*pch)); + } } rb_ary_push(ary, INT2NUM(h->h_addrtype)); #ifdef h_addr diff --git a/gc.c b/gc.c index b3200d2927..4bbcf09a94 100644 --- a/gc.c +++ b/gc.c @@ -969,7 +969,7 @@ gc_sweep() } p++; } - if (n == heaps[i].limit && freed + n > FREE_MIN) { + if (n == heaps[i].limit && freed > FREE_MIN) { RVALUE *pp; heaps[i].limit = 0; @@ -982,8 +982,10 @@ gc_sweep() freed += n; } } - malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed); - if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT; + if (malloc_increase > malloc_limit) { + malloc_limit += (malloc_increase - malloc_limit) * (double)live / (live + freed); + if (malloc_limit < GC_MALLOC_LIMIT) malloc_limit = GC_MALLOC_LIMIT; + } malloc_increase = 0; if (freed < FREE_MIN) { add_heap(); diff --git a/marshal.c b/marshal.c index 76ab4cafe8..48d71babae 100644 --- a/marshal.c +++ b/marshal.c @@ -952,11 +952,11 @@ path2module(path) } static VALUE -r_object0(arg, proc, ivp, extended) +r_object0(arg, proc, ivp, extmod) struct load_arg *arg; VALUE proc; int *ivp; - VALUE extended; + VALUE extmod; { VALUE v = Qnil; int type = r_byte(arg); @@ -975,7 +975,7 @@ r_object0(arg, proc, ivp, extended) { int ivar = Qtrue; - v = r_object0(arg, 0, &ivar, extended); + v = r_object0(arg, 0, &ivar, extmod); if (ivar) r_ivar(v, arg); } break; @@ -984,12 +984,12 @@ r_object0(arg, proc, ivp, extended) { VALUE m = path2module(r_unique(arg)); - if (NIL_P(extended)) extended = rb_ary_new2(0); - rb_ary_push(extended, m); + if (NIL_P(extmod)) extmod = rb_ary_new2(0); + rb_ary_push(extmod, m); - v = r_object0(arg, 0, 0, extended); - while (RARRAY(extended)->len > 0) { - m = rb_ary_pop(extended); + v = r_object0(arg, 0, 0, extmod); + while (RARRAY(extmod)->len > 0) { + m = rb_ary_pop(extmod); rb_extend_object(v, m); } } @@ -1002,7 +1002,7 @@ r_object0(arg, proc, ivp, extended) if (FL_TEST(c, FL_SINGLETON)) { rb_raise(rb_eTypeError, "singleton can't be loaded"); } - v = r_object0(arg, 0, 0, extended); + v = r_object0(arg, 0, 0, extmod); if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) { format_error: rb_raise(rb_eArgError, "dump format error (user class)"); @@ -1206,9 +1206,9 @@ r_object0(arg, proc, ivp, extended) VALUE data; v = rb_obj_alloc(klass); - if (! NIL_P(extended)) { - while (RARRAY(extended)->len > 0) { - VALUE m = rb_ary_pop(extended); + if (! NIL_P(extmod)) { + while (RARRAY(extmod)->len > 0) { + VALUE m = rb_ary_pop(extmod); rb_extend_object(v, m); } } @@ -1258,7 +1258,7 @@ r_object0(arg, proc, ivp, extended) "class %s needs to have instance method `_load_data'", rb_class2name(klass)); } - rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extended)); + rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extmod)); } break;