# New Ticket Created by Jonathan Stowe
# Please include the string: [perl #127700]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=127700 >
The following code will segfault after some thousand iterations:
#!perl6
use NativeCall;
my $samplerate = 44100;
my $frequency = 440;
sub gen-sin(Int $sample-rate, Int $frequency) {
gather {
loop {
for (0 .. ($samplerate/$frequency)).map({
sin(($_/($samplerate/$frequency)) * (2 * pi))}) -> $val {
take $val;
}
}
}
}
my $chan = Channel.new;
start {
for gen-sin($samplerate, $frequency).rotor(256) -> @a {
my $c = CArray[num32].new(flat @a Z @a);
$chan.send([$c, 256]);
}
}
sleep 5;
my $now = now;
react {
whenever $chan {
sleep 256/44100;
say now - $now;
$now = now;
}
}
# vim: expandtab shiftwidth=4 ft=perl6
Giving rise to (gdb output):
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffeffff700 (LWP 5923)]
0x00007ffff7aeb4ef in MVM_args_slurpy_named ()
from /home/jonathan/.rakudobrew/moar-nom/install/lib/libmoar.so
Missing separate debuginfos, use: dnf debuginfo-install
glibc-2.21-12.fc22.x86_64
(gdb) bt full
#0 0x00007ffff7aeb4ef in MVM_args_slurpy_named ()
from /home/jonathan/.rakudobrew/moar-nom/install/lib/libmoar.so
No symbol table info available.
#1 0x00007ffff7af1446 in MVM_interp_run ()
from /home/jonathan/.rakudobrew/moar-nom/install/lib/libmoar.so
No symbol table info available.
#2 0x00007ffff7b0de7e in start_thread ()
from /home/jonathan/.rakudobrew/moar-nom/install/lib/libmoar.so
No symbol table info available.
#3 0x00007ffff7bcb3a7 in uv.thread_start ()
from /home/jonathan/.rakudobrew/moar-nom/install/lib/libmoar.so
No symbol table info available.
#4 0x0000003539c07555 in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#5 0x0000003539902ded in clone () from /lib64/libc.so.6
No symbol table info available.
I'm guessing that it's the the Channel.send
This is Rakudo version 2016.02-136-g3a050fb built on MoarVM version
2016.02-25-gada3752
P.S. If the loop that feeds the channel could be at least 10x faster that would
be lovely kthx ;-)