Bug #5171

[PATCH] date_core: RB_GC_GUARD temporary strings

Added by normalperson (Eric Wong) almost 6 years ago. Updated almost 6 years ago.

Target version:
ruby -v:
ruby 1.9.4dev (2011-08-07 trunk 32885) [x86_64-linux]


ext/date/date_core.c (d_lite_inspect): RB_GC_GUARD temporary strings

test/date/test_date.rb: add test case with GC.stress=true

RSTRING_PTR() should not be used directly on function calls:
1) it may drop the VALUE reference from the stack/register set
and and allow GC to collect it
2) macros can evaluate the function call multiple times

If DNDEBUG is not defined, Date#inspect_raw also has the same issue.
However, I think removing the Date#inspect_raw code entirely is better.

If you prefer to use "git pull":
git pull git:// date_core-gc-guard

0001-ext-date-date_core.c-d_lite_inspect-RB_GC_GUARD-temp.patch View (2.26 KB) normalperson (Eric Wong), 08/09/2011 07:30 AM

0001-ext-date-date_strftime.c-date_strftime_with_tmx-RB_G.patch View - extra safety fix for tmx_zone (2.2 KB) normalperson (Eric Wong), 08/09/2011 09:55 AM


#1 [ruby-core:38865] Updated by normalperson (Eric Wong) almost 6 years ago

I also have an extra safety fix in case date_strftime_with_tmx() changes
in the future:

ext/date/date_strftime.c (date_strftime_with_tmx): RB_GC_GUARD safety fix

I don't think this has the potential to /currently/ cause errors
because the pointer is used immediately (before further
allocations). However it is still a risk if the code changes
and allocates later in the function.

There should also be a minor speedup from avoiding strlen().

git pull git:// date-tmx_zone-paranoia

#2 [ruby-core:38945] Updated by tadf (tadayoshi funaba) almost 6 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF