Subject: | ->sysread() method has problems with "size" parameter |
When calling the sysread method, the optional "size" parameter does not
seem to work as advertised. There are two failure cases.
If you pass in a small value, sysread() seems to ignore it, and returns
more data than I've requested. For instance, when I pass in a value of
1 or 2, I get 2048 bytes back, the same behavior as if I had omitted the
size parameter entirely.
If you pass in a large value (like 200000), it crashes perl with the
following backtrace:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f4983837700 (LWP 32658)]
0x00007f49826874d5 in _wordcopy_fwd_dest_aligned () from /lib/libc.so.6
(gdb) bt
#0 0x00007f49826874d5 in _wordcopy_fwd_dest_aligned () from /lib/libc.so.6
#1 0x00007f49826858ac in memmove () from /lib/libc.so.6
#2 0x0000000000497c93 in Perl_sv_setpvn (my_perl=0x19ee010, sv=0x1a192a0,
ptr=0x7f4981eb985c <Address 0x7f4981eb985c out of bounds>, len=16384)
at sv.c:3907
#3 0x00007f4982400316 in XS_Audio__FLAC__Decoder_sysread (
my_perl=<value optimized out>, cv=<value optimized out>) at
Decoder.xs:510
#4 0x000000000047b4d1 in Perl_pp_entersub (my_perl=0x19ee010) at
pp_hot.c:2847
#5 0x0000000000454c78 in Perl_runops_debug (my_perl=0x19ee010) at
dump.c:1931
#6 0x0000000000474ed4 in perl_run (my_perl=0x19ee010) at perl.c:2384
#7 0x0000000000422654 in main (argc=2, argv=0x7fff5df4ae98,
env=0x7fff5df4aeb0) at perlmain.c:113
Subject: | test.pl |
#!/usr/bin/perl
use strict;
use warnings;
use Audio::FLAC::Decoder;
my $file = Audio::FLAC::Decoder->open("foo.flac");
my $this;
my $count = 200000;
$file->sysread($this, $count);
print("length: ", length($this), "\n");