From: Yui NARUSE <naruse@...>
Date: 2011-08-09T12:11:55+09:00
Subject: [ruby-core:38868] [Ruby 1.9 - Bug #5173] [PATCH] json/generator: prevent GC of temporary strings


Issue #5173 has been updated by Yui NARUSE.


Nobuyoshi Nakada wrote:
> Anyway, JSON issues need to be reported to the upstream.

The upstream is https://github.com/flori/json

----------------------------------------
Bug #5173: [PATCH] json/generator: prevent GC of temporary strings
http://redmine.ruby-lang.org/issues/5173

Author: Eric Wong
Status: Open
Priority: Normal
Assignee: 
Category: ext
Target version: 1.9.x
ruby -v: ruby 1.9.4dev (2011-08-07 trunk 32885) [x86_64-linux]


ext/json/generator/generator.c: prevent GC of temporary strings

We need to guard temporary strings from being collected while we
append to the JSON buffer (which may allocate memory).  The
RSTRING_PAIR macro is dangerous since it preserves no pointer to
the original string VALUE, allowing GC to reap the object while
we're still using the (C) string pointer.

The included test case shows data corruption with large
Bignums without this fix.


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



-- 
http://redmine.ruby-lang.org