Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 125688
Status: open
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: dpogrebi [...] akamai.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: decode_json fails after threads->new() called.
Date: Tue, 26 Jun 2018 17:26:27 +0000
To: "bug-JSON [...] rt.cpan.org" <bug-JSON [...] rt.cpan.org>
From: "Pogrebinsky, Dmitry" <dpogrebi [...] akamai.com>
Bug: decode_json fails after threads->new() was called. Original version where I never observed this problem: tlv-mprxg:etpcas_test dpogrebi$ uname -a Darwin tlv-mprxg 16.7.0 Darwin Kernel Version 16.7.0: Tue Jan 30 11:27:06 PST 2018; root:xnu-3789.73.11~1/RELEASE_X86_64 x86_64 tlv-mprxg:etpcas_test dpogrebi$ perl -v | grep version This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level tlv-mprxg:etpcas_test dpogrebi$ New version where I faced the problem: root@32ef9a90fdc3:/shared# uname -a Linux 32ef9a90fdc3 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux root@32ef9a90fdc3:/shared# perl -v | grep version This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi Example: use strict; use JSON; use threads; sub system_thr {sleep 1} my $text='{ "device_id": "SjE4YHeUUTLQDUqgZQa3ilSrE=", "key1": "Zg6S4vfaCCqeu6+8g+", "key2": "2uyTUnft4679GDg5Sd", "key_type": "hmac_sha" }'; my $resp = decode_json $text ; my $thr = threads->new(\&system_thr, 1); for(my $i; !$thr->is_joinable(); $i++) { print "Waiting for joinable $i.\n"; sleep 1 } $thr->join(); # Not works $resp = decode_json $text ; # temproral solution. $resp = JSON->new->allow_nonref()->utf8->decode($text); print join(',', keys %$resp),"\n"; Error message: JSON text must be an object or array (but found number, string, true, false or null, use allow_nonref to allow this) at aaa.pl line 22.
Hi. Sorry for the late reply. On Wed Jun 27 02:38:20 2018, dpogrebi@akamai.com wrote: Show quoted text
> Bug: decode_json fails after threads->new() was called. > > Original version where I never observed this problem: > > tlv-mprxg:etpcas_test dpogrebi$ uname -a > > Darwin tlv-mprxg 16.7.0 Darwin Kernel Version 16.7.0: Tue Jan 30 > 11:27:06 PST 2018; root:xnu-3789.73.11~1/RELEASE_X86_64 x86_64 > > tlv-mprxg:etpcas_test dpogrebi$ perl -v | grep version > > This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin- > thread-multi-2level > > tlv-mprxg:etpcas_test dpogrebi$ > > New version where I faced the problem: > > root@32ef9a90fdc3:/shared# uname -a > > Linux 32ef9a90fdc3 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC > 2018 x86_64 x86_64 x86_64 GNU/Linux > > root@32ef9a90fdc3:/shared# perl -v | grep version > > This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64- > linux-gnu-thread-multi > > Example: > > use strict; > use JSON; > use threads; > > sub system_thr > {sleep 1} > > my $text='{ > "device_id": "SjE4YHeUUTLQDUqgZQa3ilSrE=", > "key1": "Zg6S4vfaCCqeu6+8g+", > "key2": "2uyTUnft4679GDg5Sd", > "key_type": "hmac_sha" > }'; > > my $resp = decode_json $text ; > my $thr = threads->new(\&system_thr, 1); > for(my $i; !$thr->is_joinable(); $i++) > { print "Waiting for joinable $i.\n"; sleep 1 } > $thr->join(); > > # Not works > $resp = decode_json $text ; > > # temproral solution. > $resp = JSON->new->allow_nonref()->utf8->decode($text); > print join(',', keys %$resp),"\n"; > > Error message: > > JSON text must be an object or array (but found number, string, true, > false or null, use allow_nonref to allow this) at aaa.pl line 22. >
Could you let us know a few things first? 1) The versions of JSON, JSON::PP, and JSON::XS installed on your system. 2) The value of PERL_JSON_BACKEND environmental variable (if set) 3) Does your program work when you explicitly replace JSON with JSON::PP? According to the documentation, JSON::XS "is not guaranteed to be ithread (or MULTIPLICITY-) safe and there are no plans to change this. " ( https://metacpan.org/pod/JSON::XS#(I-)THREADS ), and JSON module uses JSON::XS if it's installed. If this is the case, it's a known limitation.