Project

General

Profile

Actions

Bug #5172

closed

[PATCH] bigdecimal: RB_GC_GUARD rb_inspect() output

Added by normalperson (Eric Wong) over 13 years ago. Updated about 13 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.4dev (2011-08-07 trunk 32885) [x86_64-linux]
Backport:
[ruby-core:38862]

Description

ext/bigdecimal/bigdecimal.c: RB_GC_GUARD rb_inspect() output

We can't directly use RSTRING_PTR() on rb_inspect() because the
GC may collect the VALUE returned by rb_inspect(). This is a
problem for Symbols with long names that return non-embedded
Strings when inspected.

test/bigdecimal/test_bigdecimal.rb (test_gc): updated for BigDecimal#coerce
test/bigdecimal/test_bigmath.rb (test_gc): added test case


Files

Updated by mrkn (Kenta Murata) over 13 years ago

  • Assignee set to mrkn (Kenta Murata)

Updated by normalperson (Eric Wong) over 13 years ago

Eric Wong wrote:


Bug #5172: [PATCH] bigdecimal: RB_GC_GUARD rb_inspect() output
http://redmine.ruby-lang.org/issues/5172

If you prefer: git pull git://bogomips.org/ruby bigdecimal-gc-guard

Also, I noticed the following in ext/tk/tkutil/tkutil.c:

 rb_warning("fail to convert '%s' to string for Tk",
                RSTRING_PTR(rb_funcall(obj, rb_intern("inspect"), 0,
	   0)));

 id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str)));

I don't use or know the Tk ext at all, but the above examples do not
appear safe from a GC perspective.

--
Eric Wong

Updated by mrkn (Kenta Murata) over 13 years ago

Would you please a new ticket for the issue of tk.

Actions #4

Updated by mrkn (Kenta Murata) about 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32997.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


Merge commit r32996 from trunk:
* ext/bigdecimal/bigdecimal.c (cannot_be_coerced_into_BigDecimal):
add a new function for raising error when an object cannot coerce
into BigDecimal. [Bug #5172]
* ext/bigdecimal/bigdecimal.c (BigDecimalValueWithPrec): use
cannot_be_coerced_into_BigDecimal function.
* ext/bigdecimal/bigdecimal.c (BigMath_s_exp): ditto.
* ext/bigdecimal/bigdecimal.c (BigMath_s_log): ditto.
* test/bigdecimal/test_bigdecimal.rb: test for the avobe changes.
* test/bigdecimal/testbase.rb (under_gc_stress): add a new utility
method to run tests under the condition of GC.stress = true.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0