in reply to Re^6: JSON::XS and blessings
in thread JSON::XS and blessings

:P Heisenbugs happen… they are, by nature, not repeatable.

Replies are listed 'Best First'.
Re^8: JSON::XS and blessings
by cshavit (Novice) on Oct 15, 2015 at 13:07 UTC
    Haha, yes. Except that in this case it's totally repeatable. One virtual server always has a live cat, the other always has a dead cat.

      You have already stated that the problem only occurs when Apache is involved.

      Have you stopped and restarted Apache?

      Does the problem persist when the Perl script is run as a CGI program instead of being run as a mod_perl script?

      Check the versions of all modules loaded into mod_perl and compare them between the two machines:

      for my $module (sort keys %INC) { (my $namespace = $module) =~ s!/!::!g; $namespace =~ s/\.pm$//; print sprintf "Module: %s; Path: %s; Size: %d; VERSION: %s\n", $module, $INC{$module}, -s($INC{$module}), $namespace->VERSION +; }

      Note that you need to run the above output from within Apache, because when run from the shell everything seems to be OK for you.

        Thanks! It was a great idea to compare the %INC of the two virtual servers. I did, and unfortunately they are identical. %INC in both has about 350 keys, and the outputs including version numbers are identical.

        And yes, I restarted apache several times while debugging this.

        Back to the original problem: my understanding is that decode_json('{"a":true}')returns a ref to a hash with key 'a' and value true which isa JSON:PP:Boolean. If there a way to print attributes of decode_json('{"a":true}')->{a} such that I can compare them between the two servers?

        Running on both virtual server apache servers,

        my $json = '{"a":true}'; $d = decode_json($json); printf "Dumper: %s<br>\n",Dumper($d);

        prints the same: Dumper: $VAR1 = { 'a' => bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ) };

        Yet encode_json($d) fails on one and works correctly on the other.