From: Eric Wong Date: 2012-01-15T16:56:42+09:00 Subject: [ruby-core:42134] Re: [ruby-trunk - Bug #5888][Assigned] JSON unittest fails Yui NARUSE wrote: > filed it to GCC's tracker. I don't believe this is a GCC bug: space for buf[4] can be reclaimed as soon as execution finishes in the scope where buf[4] was declared. > For JSON, following is simple patch: This was always a bug, we were just lucky because GCC wasn't as aggressive when popping the stack. > diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c > index d1d14c7..1773616 100644 > --- a/ext/json/parser/parser.c > +++ b/ext/json/parser/parser.c > @@ -1293,6 +1293,7 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) > { > char *p = string, *pe = string, *unescape; > int unescape_len; > + char buf[4]; > > while (pe < stringEnd) { > if (*pe == '\\') { > @@ -1325,7 +1326,6 @@ static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd) > if (pe > stringEnd - 4) { > return Qnil; > } else { > - char buf[4]; > UTF32 ch = unescape_unicode((unsigned char *) ++pe); > pe += 3; > if (UNI_SUR_HIGH_START == (ch & 0xFC00)) { > ----------------------------------------