This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Latest perl JSON::XS failing when threaded


I updated cygwin today, and now perl JSON::XS fails to be able to
decode json data if it is run in a multi-threaded script.  I tested
both x86_64 and x86 32-bit versions of cygwin, and they both have the
issue: once I launch a new thread, JSON::XS refuses to parse anything,
even in the primary thread and even if the launched thread didn't do
any json work.  The error is similar to this for a decode_json() call:

Thread 1 terminated abnormally: JSON text must be an object or array [...]

Note that it is complaining about the arg not being an object when
decoding takes a string. If I pass it an object, it accepts the
wrong-typed var and fails with a parsing error.

I forcefully uninstalled JSON::XS and the bug goes away.

I'll append a simple test script that tries to do a decrypt_json() in a thread.

..wayne..
--------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use JSON::XS;

print "Normal:\n"; # This works:
test_json_xs();

print "Threaded:\n"; # This throws an error:
my $t = threads->create(\&test_json_xs);
$t->detach();
exit;

sub test_json_xs
{
    my $test = <<EOT;
  {
    "testing": [ "one", "two", "three" ]
  }
EOT
    my $try = decode_json($test);
    if (ref $try->{testing} eq 'ARRAY') {
        print "OK!\n";
    } else {
        print "FAIL!\n";
    }
}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]