Skip Menu |
Report information
Id: 131871
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: smls75 [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: regex
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [CONC] [REGEX] Regex code block closing over lexical variable, is not threadsafe
From: Sam S <smls75 [...] gmail.com>
To: Rakudo Bugtracker <rakudobug [...] perl.org>
Date: Wed, 9 Aug 2017 22:06:32 +0200
This bug was found as a side-effect of RT #131870, but might be a separate issue: ➜ await ^10 .map: -> $i { start { "".match(/ { say $i } /) } } 7 7 6 6 7 8 9 9 9 9 Somehow, multiple iterations see the same value for the closed-over variable `$i`. Without the `await` and `start`, it prints each number from 0 to 9 exactly once, like it should. --- Note that the problem is only with *code blocks* inside regexes. When a lexical variable is interpolated into the top-level of a regex directly, things seem to work fine: ➜ say await ^10 .map: -> $i { start { "0123456789".match(/ $i /) } } (「0」 「1」 「2」 「3」 「4」 「5」 「6」 「7」 「8」 「9 --- Bot-friendly version that reliably prints `False`, even though it should print `True`: my $c = Channel.new; (await ^100 .map: -> $i { start "".match(/ { $c.send: $i } /) }); $c.close; say $c.sort.list eqv (^100).list; According to bisectable6 and committable6 this prints `False` for all past Perl 6 releases, so it's not a regression but rather an old bug.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org