Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
This is a bug report for perl from email@example.com,
Off-by-one when truncating *shared* array by: $#ary -= $chop_this_many
What should happen: Shared array max index should drop to a new, lower value.
What does happen: Actual new max index is *too large by one* (Too few elements chopped off)
See additional notes and environment details after example code and example output below.
Before truncation, shared array highest index is: 9
Shared array now contains: 0 | 1 | 2 | 3 | 4 | 5
$ cat perl-shared-array-truncate.pl
### First with an ordinary array
printf "Before truncation, ordinary array highest index is: %s\n", $#ordinary_array;
### Then try it with a shared array
printf "Before truncation, shared array highest index is: %s\n", $#shared_array;
----- environment and notes -----
$ uname -a
$ /usr/bin/perl -v
Although I am using the "threads" module in this example script, I am not spawning
I am aware that for removing a small number of elements I can "pop" a few times however
I am aware that splice is not allowed with shared arrays. This truncation does not appear
uses this method to truncate an array.
I am aware of Thread::Queue.
I have also repeated this on these environments with same results:
Linux xxxxxxxx 2.6.32-358.2.1.el6.centos.plus.x86_64 #1 SMP Wed Mar 13 02:09:07 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Linux andy2 3.11.0-26-generic #45-Ubuntu SMP Tue Jul 15 04:02:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Thank you very much.
Site configuration information for perl 5.18.2:
Configured by Red Hat, Inc. at Tue Jan 7 14:45:19 UTC 2014.
Summary of my perl5 (revision 5 version 18 subversion 2) configuration:
Locally applied patches:
@INC for perl 5.18.2:
Environment for perl 5.18.2:
On Sat, Oct 11, 2014 at 03:34:23AM -0700, via RT wrote:
Thanks for the report. Now fixed in blead by the following two commits:
threads::shared "$#shared = N" off-by-one error
threads: $#shared = N should destroy