[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79511] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150]
From:
Eric Wong <normalperson@...>
Date:
2017-02-13 01:04:41 UTC
List:
ruby-core #79511
Eric Wong <normalperson@yhbt.net> wrote:
> naruse@ruby-lang.org wrote:
> > Prevent GC by volatile [Bug #13150]
> >
> > test/ruby/test_marshal.rb test_context_switch (load) and test_gc (dump)
> > are failed on FreeBSD 10.3 and gcc7 (FreeBSD Ports Collection) 7.0.0
> > 20170115 (experimental); RB_GC_GUARD looks not worked well.
>
> Have you tried to experiment with making RB_GC_GUARD stronger
> for gcc7, instead? There may be similar bugs, and I would rather
> improve RB_GC_GUARD than add volatiles (which are more subtle
> and have more variance between implementations).
I still support fixing RB_GC_GUARD to be stronger for GCC7.
But in marshal.c, I think we can use klass==0 to hide the object
and use rb_gc_force_recycle, instead. AFAIK,
rb_gc_force_recycle is safe if the object has klass==0 for its
entire lifetime.
How about the following?
diff --git a/marshal.c b/marshal.c
index d628daa4de..b9c9e6a03e 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1024,9 +1024,9 @@ VALUE
rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
{
struct dump_arg *arg;
- volatile VALUE wrapper; /* used to avoid memory leak in case of exception */
+ VALUE wrapper; /* used to avoid memory leak in case of exception */
- wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg);
+ wrapper = TypedData_Make_Struct(0, struct dump_arg, &dump_arg_data, arg);
arg->dest = 0;
arg->symbols = st_init_numtable();
arg->data = rb_init_identtable();
@@ -1053,8 +1053,8 @@ rb_marshal_dump_limited(VALUE obj, VALUE port, int limit)
rb_io_write(arg->dest, arg->str);
rb_str_resize(arg->str, 0);
}
- clear_dump_arg(arg);
- RB_GC_GUARD(wrapper);
+ free_dump_arg(arg);
+ rb_gc_force_recycle(wrapper);
return port;
}
@@ -2038,7 +2038,7 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc)
{
int major, minor, infection = 0;
VALUE v;
- volatile VALUE wrapper; /* used to avoid memory leak in case of exception */
+ VALUE wrapper; /* used to avoid memory leak in case of exception */
struct load_arg *arg;
v = rb_check_string_type(port);
@@ -2053,7 +2053,7 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc)
else {
io_needed();
}
- wrapper = TypedData_Make_Struct(rb_cData, struct load_arg, &load_arg_data, arg);
+ wrapper = TypedData_Make_Struct(0, struct load_arg, &load_arg_data, arg);
arg->infection = infection;
arg->src = port;
arg->offset = 0;
@@ -2084,8 +2084,8 @@ rb_marshal_load_with_proc(VALUE port, VALUE proc)
if (!NIL_P(proc)) arg->proc = proc;
v = r_object(arg);
- clear_load_arg(arg);
- RB_GC_GUARD(wrapper);
+ free_load_arg(arg);
+ rb_gc_force_recycle(wrapper);
return v;
}
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>