develooper Front page | perl.perl5.porters | Postings from April 2008

Re: [perl #53244] perl-5.10.0-33733 assertion with JSON::XS-2.2

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
April 25, 2008 06:58
Subject:
Re: [perl #53244] perl-5.10.0-33733 assertion with JSON::XS-2.2
Message ID:
20080425135837.GP79799@plum.flirble.org
On Wed, Apr 23, 2008 at 06:32:31AM -0700, david @ davidfavor. com wrote:

> JSON::XS and other XS modules fail with assertions of the form:
> 
>     t/02_error................perl: XS.xs:1418: decode_json:
>        Assertion `!((((_svi)->sv_flags & (0x00004000|0x00008000)) == 0x00008000) &&
>        (((svtype)((_svi)->sv_flags & 0xff)) == SVt_PVGV ||
>        ((svtype)((_svi)->sv_flags & 0xff)) == SVt_PVLV))' failed.
> 
> JSON::XS-2.1 tests clean with perl-5.8.8 latest and perl-5.10.0-33733.
> 
> JSON::XS-2.2 tests clean with perl-5.8.8 latest and fails with all of
> perl-5.10.0-33733 and other old patch levels I have laying around, back
> through several 336xx series patches.

I'm not quite sure why you consider a module that was released *after* 5.10.0
that has a test failure to be a bug in 5.10.0, given that the version
of the module at the time of the release passed.

The assertion failure is due to a change in decode_json, from

  if (json->flags & F_MAXSIZE && SvCUR (string) > DEC_SIZE (json->flags))
    croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
           (unsigned long)SvCUR (string), (unsigned long)DEC_SIZE (json->flags));

to

  if (SvCUR (string) > json->max_size && json->max_size)
    croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
           (unsigned long)SvCUR (string), (unsigned long)json->max_size);


It can be fixed with the appended patch.

You mention "other XS modules". Which other XS modules?

Nicholas Clark

--- XS.xs~	2008-04-05 19:14:48.000000000 +0100
+++ XS.xs	2008-04-25 12:10:22.000000000 +0100
@@ -1415,7 +1415,7 @@
   SvGETMAGIC (string);
   SvUPGRADE (string, SVt_PV);
 
-  if (SvCUR (string) > json->max_size && json->max_size)
+  if (SvPOKp(string) && SvCUR (string) > json->max_size && json->max_size)
     croak ("attempted decode of JSON text of %lu bytes size, but max_size is set to %lu",
            (unsigned long)SvCUR (string), (unsigned long)json->max_size);
 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About