public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Latest perl JSON::XS failing when threaded
@ 2016-03-03 23:54 Wayne Davison
  2016-03-04  8:53 ` Achim Gratz
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wayne Davison @ 2016-03-03 23:54 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-06-17 19:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-03 23:54 Latest perl JSON::XS failing when threaded Wayne Davison
2016-03-04  8:53 ` Achim Gratz
2016-03-04 19:19   ` Achim Gratz
2016-03-05 17:51 ` Achim Gratz
2016-03-13 17:21 ` Achim Gratz
2016-03-15 22:20   ` Wayne Davison
2016-06-17 20:29     ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).