New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List::Util reduce returns wrong answer because length(string) returns wrong value #13885
Comments
From @jikamensCreated by @jikamensThis is a bug report for perl from jik@kamens.us, ----------------------------------------------------------------- This is a weird bug for which I'm unfortunately not going to be able I want to use reduce in List::Util to find the longest string in a my $longest = reduce { length($a) > length($b) ? $a : $b } @names; At one point, my script executes this line of code with @names set to main::envelope_names(/home/jik/foo/to_sql.pl:305):
Wow, that's exceedingly weird, don't you think? If I modify the reduce main::envelope_names(/home/jik/foo/to_sql.pl:305):
Note how the first time the reduce block is called, it correctly There appears to be something manifestly bizarre about the particular DB<<21>> p &envelope_names("Aaaaaa", "Aaaaaa-Bbbbbbb", "Bbbbbbb") NOTE: The strings in question aren't actually "Aaaaaa", Perl Info
|
From @ikegamiOn Fri, May 30, 2014 at 1:31 PM, via RT <perlbug-followup@perl.org> wrote:
Looks like a missing mg_get |
The RT System itself - Status changed from 'new' to 'open' |
From @ikegamiOn Fri, May 30, 2014 at 8:19 PM, Eric Brine <ikegami@adaelis.com> wrote:
If so, you should be able to work around the problem using reduce { ... } map "$_", @names; |
From @jikamensOn 05/30/2014 08:21 PM, Eric Brine via RT wrote:
This workaround does not work, i.e., the same problem occurs even when I |
From @ikegamiOn Sat, May 31, 2014 at 10:51 PM, Jonathan Kamens <jik@kamens.us> wrote:
And I wasn't able to reproduce the problem using tied variable. Are you |
From @jikamensSV = PVMG(0x23a59c0) at 0x2870310 |
From @demerphqOn 2 June 2014 06:34, Jonathan Kamens <jik@kamens.us> wrote:
MG_LEN is clearly broken. Can you do it again before and after the reduce call? Yves -- |
From @ikegamiOn Tue, Jun 3, 2014 at 4:26 AM, demerphq <demerphq@gmail.com> wrote:
Code to reproduce: use strict; use List::Util qw( reduce ); my @names = qw( Aaaaaa Aaaaaa-Bbbbbbb Bbbbbbb ); my $longest = reduce { my $alen = length($a); my $blen = length($b);
The C<MG_LEN> associated with the elements of C<@names> is correct both |
From @jikamensHere's a Dump of the relevant member of the list before the reduce, both Before list member: On 06/03/2014 04:27 AM, yves orton via RT wrote:
|
From @iabynI can reproduce the issue on blead now. use List::Util qw(reduce); with a debugging build gives $ ./perl -Ilib ~/tmp/p clearly the utf8 cached length in magic is getting corrupted. It's been present since 5.10.0. -- |
From @tonycozOn Wed Jun 04 03:19:07 2014, davem wrote:
This is a bug in List::Util::reduce(). It uses SvSetSV() to copy SVs around, which doesn't call set magic. The sequence in Dave's sample would be: args[1] copied into return temp (no magic), aliased into $a Replacing the 3 SvSetSV() calls with SvSetMagicSV() fixes the problem. Tony |
From @leonerdOn Mon, 16 Jun 2014 17:06:46 -0700
Can you throw me that in an 'rt' bug and I'll remember to fix it... -- leonerd@leonerd.org.uk |
From @tonycozOn Mon Jun 16 17:06:46 2014, tonyc wrote:
I think it may already have been reported upstream as https://rt.cpan.org/Public/Bug/Display.html?id=63211 Tony |
From @tonycozOn Mon Jun 16 17:36:52 2014, tonyc wrote:
Since this is an upstream bug, I'm rejecting this ticket. From the note on the CPAN ticket, this will be fixed in the list release of Scalar-List-Utils. Tony |
@tonycoz - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#121992 (status was 'rejected')
Searchable as RT121992$
The text was updated successfully, but these errors were encountered: