# New Ticket Created by  G. Todd 
# Please include the string:  [perl #122810]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=122810 >


Using masak's "p6-golfed" word counter:

    perl6 -e `.say for (bag slurp.words).pairs.sort(*.value).reverse[^10]'

on this file http://www.gutenberg.org/files/24007/24007-8.txt

which I have saved as UTF-8 text in La_psychologie_des_foules.txt

iconv -f ISO-8859-1 -t UTF-8 24007-8.txt > La_psychologie_des_foules.txt
perl6 -e `.say for (bag slurp.words).pairs.sort(*.value).reverse[^10]'
La_psychologie_des_foules.txt

I get this error:

Arg has not been flattened in slurpy_positional
   in method new at src/gen/m-CORE.setting:17249
   in sub bag at src/gen/m-CORE.setting:17906

src/gen/m-CORE.setting:17249 comes from
src/core/Baggy.pm
https://github.com/rakudo/rakudo/blob/nom/src/core/Baggy.pm#L24

"slurpy_positional" shows up under nqp/MoarVM/:
nqp/MoarVM/src/core/interp.c
and nqp/MoarVM/src/core/args.c in a while(){} around linke 515 we have:

 if (arg_info.flags & MVM_CALLSITE_ARG_FLAT) {,
            MVM_exception_throw_adhoc(tc, "Arg has not been flattened
in slurpy_positional");,
 },

so my guess is that this is a Baggy/Arg <--> moar bug or a not yet
implemented bit in the switch/case statements ( MVM_CALLSITE_ARG_etc )
in that file.

Neither perl6-j and perl6-p have this error.

Other data points:

The file is 6294 lines long and has many words to count:
wc La_psychologie_des_foules.txt
6294 53930 369219 La_psychologie_des_foules.txt

If I reduce the size of the file this the code works without the error

head -n 5655 > short_La_psychologie_des_foules.txt
wc short_La_psychologie_des_foules.txt
5655   49190  334666 short_La_psychologie_des_foules.txt

This seems to predictably occur when the file is > 5654 lines long.
Creating a file with 5655 lines and removing characters gradually you
can create a file at the exact size limit to provoke a crash.
Larger files with more lines and fewer "words" also work. Trying to
find a pattern by aliasing the above code to p6wordcount and then
passing it lots of text files:

    for i in *txt; do echo ""; wc $i ; p6wordcount $i; done

gives only faint glimmers of light ...  it seems where files have
numbers of words > ~49000 the error appears. Files with large numbers
of characters don't seem to have the same effect though, i.e. as long
as the number of words is within the limit.

Hope that helps someone track this down.

Reply via email to