timo / json_fast

a naive imperative json parser in perl6, to evaluate performance against JSON::Tiny
Artistic License 2.0
27 stars 20 forks source link

race conditions #24

Closed bduggan closed 7 years ago

bduggan commented 7 years ago

Hi Timo,

I'm running into what seems to be a race condition of some sort. The code below illustrates the problem (note that this code works fine with e.g. JSON::Tiny) --

#!/usr/bin/env perl6

use JSON::Fast;

my $parseme = q:to/DONE/;
{ "a" : "1" }
{ "a" : "2" }
{ "a" : "3" }
{ "a" : "4" }
{ "a" : "5" }
{ "a" : "6" }
DONE

$parseme ~= $parseme for 1..10;

my @out = $parseme.lines
    .race(:degree(8),:batch(1))
    .map: { to-json( from-json($_) ); };

This is the error that occurs sometimes:

This type cannot unbox to a native string: P6opaque, Hash
  in sub str-escape at /usr/local/Cellar/rakudo-star/2017.04/share/perl6/site/sources/7F9536176FAF86BE6A849D6381F97144496BD662 (JSON::Fast) line 5
  in sub to-json at /usr/local/Cellar/rakudo-star/2017.04/share/perl6/site/sources/7F9536176FAF86BE6A849D6381F97144496BD662 (JSON::Fast) line 37
  in sub to-json at /usr/local/Cellar/rakudo-star/2017.04/share/perl6/site/sources/7F9536176FAF86BE6A849D6381F97144496BD662 (JSON::Fast) line 59
  in block  at json-faster.p6 line 18
timo commented 7 years ago

this was also fixed in c8217712