Project

General

Profile

Bug #13150 ยป ruby_2_3_gcc7.patch

hsbt (Hiroshi SHIBATA), 07/19/2017 03:02 AM

View differences:

include/ruby/ruby.h
551 551
	((type) == RUBY_T_FLOAT) ? RB_FLOAT_TYPE_P(obj) : \
552 552
	(!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == (type)))
553 553

  
554
/* RB_GC_GUARD_PTR() is an intermediate macro, and has no effect by
555
 * itself.  don't use it directly */
556 554
#ifdef __GNUC__
557
#define RB_GC_GUARD_PTR(ptr) \
558
    __extension__ ({volatile VALUE *rb_gc_guarded_ptr = (ptr); rb_gc_guarded_ptr;})
559
#else
560
#ifdef _MSC_VER
555
#define RB_GC_GUARD(v) \
556
    (*__extension__ ({ \
557
	volatile VALUE *rb_gc_guarded_ptr = &(v); \
558
	__asm__("" : : "m"(rb_gc_guarded_ptr)); \
559
	rb_gc_guarded_ptr; \
560
    }))
561
#elif defined _MSC_VER
561 562
#pragma optimize("", off)
562 563
static inline volatile VALUE *rb_gc_guarded_ptr(volatile VALUE *ptr) {return ptr;}
563 564
#pragma optimize("", on)
565
#define RB_GC_GUARD(v) (*rb_gc_guarded_ptr(&(v)))
564 566
#else
565 567
volatile VALUE *rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val);
566 568
#define HAVE_RB_GC_GUARDED_PTR_VAL 1
567 569
#define RB_GC_GUARD(v) (*rb_gc_guarded_ptr_val(&(v),(v)))
568 570
#endif
569
#define RB_GC_GUARD_PTR(ptr) rb_gc_guarded_ptr(ptr)
570
#endif
571

  
572
#ifndef RB_GC_GUARD
573
#define RB_GC_GUARD(v) (*RB_GC_GUARD_PTR(&(v)))
574
#endif
575 571

  
576 572
#ifdef __GNUC__
577 573
#define RB_UNUSED_VAR(x) x __attribute__ ((unused))
marshal.c
1022 1022
rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
1023 1023
{
1024 1024
    struct dump_arg *arg;
1025
    VALUE wrapper; /* used to avoid memory leak in case of exception */
1025
    volatile VALUE wrapper; /* used to avoid memory leak in case of exception */
1026 1026

  
1027 1027
    wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg);
1028 1028
    arg->dest = 0;
......
1051 1051
	rb_io_write(arg->dest, arg->str);
1052 1052
	rb_str_resize(arg->str, 0);
1053 1053
    }
1054
    clear_dump_arg(arg);
1055
    RB_GC_GUARD(wrapper);
1054
    free_dump_arg(arg);
1055
    rb_gc_force_recycle(wrapper);
1056 1056

  
1057 1057
    return port;
1058 1058
}
......
2044 2044
{
2045 2045
    int major, minor, infection = 0;
2046 2046
    VALUE v;
2047
    VALUE wrapper; /* used to avoid memory leak in case of exception */
2047
    volatile VALUE wrapper; /* used to avoid memory leak in case of exception */
2048 2048
    struct load_arg *arg;
2049 2049

  
2050 2050
    v = rb_check_string_type(port);
......
2090 2090

  
2091 2091
    if (!NIL_P(proc)) arg->proc = proc;
2092 2092
    v = r_object(arg);
2093
    clear_load_arg(arg);
2094
    RB_GC_GUARD(wrapper);
2093
    free_load_arg(arg);
2094
    rb_gc_force_recycle(wrapper);
2095 2095

  
2096 2096
    return v;
2097 2097
}
test/ruby/test_marshal.rb
645 645
    c = Bug9523.new
646 646
    assert_raise_with_message(RuntimeError, /Marshal\.dump reentered at marshal_dump/) do
647 647
      Marshal.dump(c)
648
      GC.start
649
      1000.times {"x"*1000}
650
      GC.start
648 651
      c.cc.call
649 652
    end
650 653
  end