Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load-yaml not threadsafe #19

Open
jnthn opened this issue Feb 2, 2018 · 10 comments
Open

load-yaml not threadsafe #19

jnthn opened this issue Feb 2, 2018 · 10 comments

Comments

@jnthn
Copy link

jnthn commented Feb 2, 2018

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
Copy link
Author

jnthn commented Feb 2, 2018

After a look through the module, it's not immediately obvious to me that it's doing anything wrong; it may be a compilation bug with code blocks inside of a before.

@Leont
Copy link
Owner

Leont commented Feb 3, 2018

My installed perl6 is somewhat old (2017.08-79-g4b02b8aad), I can't reproduce it there. This may be a regression.

@Leont
Copy link
Owner

Leont commented Oct 5, 2018

Is this still an issue?

@Leont
Copy link
Owner

Leont commented Oct 5, 2018

The Grammar reenters the Grammar engine at some places, I would guess that to be the root of the issue.

@jnthn
Copy link
Author

jnthn commented Oct 5, 2018

I think it may be a problem with before; I'll have to dig a bit further.

@japhb
Copy link

japhb commented Mar 20, 2020

Behavior recreated with current(ish) Rakudo; line numbers have changed though (and again, no errors without race):

$ perl6 -v
This is Rakudo version 2020.02.1-183-g70ac9b72e built on MoarVM version 2020.02.1-44-g04005cf43
implementing Raku 6.d.

$ 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 .../site/sources/ADB31520994572F18CE4EC4457E5E9321A31301C (YAMLish) line 296
Use of Nil in string context
in block at .../site/sources/ADB31520994572F18CE4EC4457E5E9321A31301C (YAMLish) line 289
Use of Nil in string context
in block at .../site/sources/ADB31520994572F18CE4EC4457E5E9321A31301C (YAMLish) line 289
Use of Nil in string context
in block at .../site/sources/ADB31520994572F18CE4EC4457E5E9321A31301C (YAMLish) line 289
A worker in a parallel iteration (hyper or race) initiated here:
in block at -e line 1

Died at:
Couldn't parse YAML
in sub load-yaml at .../site/sources/ADB31520994572F18CE4EC4457E5E9321A31301C (YAMLish) line 951
in block at -e line 1

@pjdurai
Copy link

pjdurai commented Oct 3, 2020

Came here to report this. Can confirm this is still an issue.
I had to put the usage of 'load-yaml' method inside a 'lock.protect' to get my script working.

❯❯❯ rakudo --version
This is Rakudo version 2020.05.1 built on MoarVM version 2020.05
implementing Raku 6.d.

@Leont
Copy link
Owner

Leont commented Oct 5, 2020

I had to put the usage of 'load-yaml' method inside a 'lock.protect' to get my script working.

Unless @jnthn has a better idea, I guess I'll do that

@patrickbkr
Copy link

I am still hitting this with Rakudo 2022.07.

@patrickbkr
Copy link

@lizmat Given this is actually a compile time bug of code blocks in before, do I assume correctly, that this issue is likely to be gone on RakuAST all by itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants