in reply to Re: List::MoreUtils' minmax bug?
in thread List::MoreUtils' minmax bug?

I'm on perl 5.22.0 and List::MoreUtils 0.413.

Dumping $envres->[2][0]{time} with Devel::Peek reveals something:

When there is no warning:

SV = PVNV(0x279ae10) at 0x25ca100 REFCNT = 1 FLAGS = (POK,IsCOW,pPOK) IV = 0 NV = 0.00217268600128591 PV = 0x2895f60 "0.0022"\0 CUR = 6 LEN = 10 COW_REFCNT = 3

When there is a warning:

SV = PVNV(0x196bf40) at 0x170b110 REFCNT = 1 FLAGS = (POK,pPOK) IV = 0 NV = 0.002889619519036 PV = 0x1a6dbb0 "0.003"\0 CUR = 5 LEN = 10 Use of uninitialized value $max in numeric le (<=) at lib/Bencher/Form +atter/ScaleTime.pm line 30.

Trying this with a few other perls: doesn't happen in 5.10.1, always seems to happen in 5.18.4, never seems to happen in 5.20.3 happens too in 5.20.3.

Replies are listed 'Best First'.
Re^3: List::MoreUtils' minmax bug?
by Anonymous Monk on Mar 16, 2016 at 18:41 UTC

    Wow, Bencher::Backend has a lot of code, it's difficult to tell where $envres comes from. Unfortunately I think you'll need to boil it down to a code snippet that reproduces the problem (which still smells like a bug).

    I did notice that in one place $envres comes from JSON. Here's an interesting one...

    use warnings; use strict; use List::MoreUtils 'minmax'; use JSON::MaybeXS 'decode_json'; use Data::Dump 'dump'; my $envres = decode_json( q# [ [], [], [{"time":"0.0022"},{"time":false}] ] # ); dump $envres; my ($min, $max) = minmax(map {$_->{time}} @{$envres->[2]}); dump $min, $max; __END__ [ [], [], [ { time => 0.0022 }, { time => bless(do{\(my $o = 0)}, "JSON::PP::Boolean") }, ], ] Segmentation fault (core dumped)
      Nope, JSON is not involved in this case. I am now able to produce a simpler test case, I'm updating my original post.