yamlish icon indicating copy to clipboard operation
yamlish copied to clipboard

load-yaml not threadsafe

Open jnthn opened this issue 7 years ago • 10 comments

We've had a test or two that occasionally fails in the cro distribution's test suite. Today I finally got around to hunting it down, and it boiled down to the load-yaml sometimes blowing up if called from two threads at the same time. Thankfully, it's easy to reproduce reliably with a one-liner that users this module (note the second example that crashes adds race):

$ perl6 -e 'use YAMLish; my $yaml = "foo:\n  -bar: 42"; for ^1000 { load-yaml $yaml }'
$ perl6 -e 'use YAMLish; my $yaml = "foo:\n  -bar: 42"; race for ^1000 { load-yaml $yaml }'
Use of Nil in string context
  in block  at /home/jnthn/dev/MoarVM/install/share/perl6/site/sources/9D54CB20630A6D95A459E8D21558CE9627DA4464 (YAMLish) line 145
Use of Nil in string context
  in block  at /home/jnthn/dev/MoarVM/install/share/perl6/site/sources/9D54CB20630A6D95A459E8D21558CE9627DA4464 (YAMLish) line 145
Use of Nil in string context
  in block  at /home/jnthn/dev/MoarVM/install/share/perl6/site/sources/9D54CB20630A6D95A459E8D21558CE9627DA4464 (YAMLish) line 145
A worker in a parallel iteration (hyper or race) initiated here:
  in block <unit> at -e line 1

Died at:
    Couldn't parse YAML
      in sub load-yaml at /home/jnthn/dev/MoarVM/install/share/perl6/site/sources/9D54CB20630A6D95A459E8D21558CE9627DA4464 (YAMLish) line 735
      in block  at -e line 1

jnthn avatar Feb 02 '18 16:02 jnthn