On Fri Sep 20 16:31:00 2013, Hugmeir wrote: > Yes. The problem for both is that x_GLOB_ENTRIES should be thread-local, > but is unintentionally being shared between threads. > > This patch solves the issue: > > diff --git a/ext/File-Glob/Glob.xs b/ext/File-Glob/Glob.xs > index b3705b3..181dbbc 100644 > --- a/ext/File-Glob/Glob.xs > +++ b/ext/File-Glob/Glob.xs > @@ -396,6 +396,13 @@ PPCODE: > iterate(aTHX_ doglob_iter_wrapper); > SPAGAIN; > > +void > +CLONE(...) > +CODE: > + PERL_UNUSED_ARG(items); > + MY_CXT_CLONE; > + MY_CXT.x_GLOB_ENTRIES = NULL; > + > BOOT: > { > #ifndef PERL_EXTERNAL_GLOB > > > But it means that this: > > ./perl -Ilib -Mthreads -E 'sub foo {scalar glob("*")} foo(); say > threads->create(\&foo)->join() for 1..3' > > Will return "Artistic" four times, rather than "Artristic" followed by the > second file thrice. If the latter is the desired behavior, then we need to > hv_dup(x_GLOB_ENTRIES) in CLONE() as well. Yes, the latter. That would be backward-compatible with when File::Glob still worked. Thank you for tackling this. This is entirely my fault, as I was the one who moved it from Perl space to XS. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org:443/rt3/Ticket/Display.html?id=119897Thread Previous | Thread Next