delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/03/03/18:55:22

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; q=dns; s=default; b=nuU8NCMLm1CJq6lbgAapSMYp2ZGbS
CCmoDkB517KjGt76xVWEdS6jussBsrZra1ic1+JQeTggtOapiFWHbBjkyxw+AwrF
FuX50tk76l9xXA6bwoEpP09B/cXazEjv66E0kJ4bXOCVDusojzXQMheBeNbP1Qtf
oV4YHC+/+MLS0E=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:from:date:message-id:subject:to
:content-type; s=default; bh=TPr/W8R0uTEyjBg8K9iT+a2cclI=; b=aKt
9miDln/2ihvHZmtVERgkp+K80GaFIQPDuCFm5C4+8qTqFMXqos2wDa844uydEtVz
ThhgYVyyjCOhwSCoU3+tshOys2t0gqSZLdi6SKVPS0DvTLtsKqitMNh7p16CKPkC
RYDbfTjXHUkwthob8sIgCsAudmvgM8SmHszS2tqg=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=launched, forcefully, OK, decode
X-HELO: homiemail-a104.g.dreamhost.com
X-Gm-Message-State: AD7BkJIRkxkjG5luy/RhBaT05bXUjX8mJLXjK4LgVEyszY6Bm7wpeIK1lZkA2HZU42uZzEd7Eq+xBdTS5/giiQ==
X-Received: by 10.182.111.137 with SMTP id ii9mr3896536obb.77.1457049288956; Thu, 03 Mar 2016 15:54:48 -0800 (PST)
MIME-Version: 1.0
From: Wayne Davison <wayne AT opencoder DOT net>
Date: Thu, 3 Mar 2016 15:54:29 -0800
X-Gmail-Original-Message-ID: <CAHSx_SvqC+ajoCQ01S+j8wrwqG0B=m0mK5O+o4PQyS-THBWSYQ AT mail DOT gmail DOT com>
Message-ID: <CAHSx_SvqC+ajoCQ01S+j8wrwqG0B=m0mK5O+o4PQyS-THBWSYQ@mail.gmail.com>
Subject: Latest perl JSON::XS failing when threaded
To: cygwin <cygwin AT cygwin DOT com>
X-IsSubscribed: yes

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019