On 09/27/2015 11:58 PM, Benjamin Goldberg (via RT) wrote:
# New Ticket Created by Benjamin Goldberg
# Please include the string: [perl #126208]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=126208 >
The code at https://gist.github.com/BenGoldberg1/bc39a9a31eaeb733012a creates
many threads for the task of sorting numbers as they are sent to a channel.
Roughly twice as many threads are created as there are distinct values.
The output should be a list of random numbers, sorted.
Instead, it produces a error message; changing the number of element to be
sorted causes the error message to change. This leads me to conclude that the
problem is memory corruption of some sort.
One of the error messages was:
Attempt to return outside of any Routine in block <unit> at /tmp/4c1CWudfwj:33
I think this error message is correct
#!/usr/bin/env perl6
use v6;
sub sort-promise ($c) {
start {
my @same;
earliest $c {
more $c { push @same, $c.receive }
done $c { return }
}
You try to return from a routine through a start { } boundary -- I don't
think that's allowed.
Another error message was:
Cannot send a message on a closed channel in block <unit> at
/tmp/T9gWZ7YfGJ:33
Can be correct as well. I don't think you wait with the .close until all
the other tasks are done.
Another error message was:
Cannot receive a message on a closed channel in block <unit> at
/tmp/rPtHPIxsTw:33
Same here.