develooper Front page | perl.perl5.porters | Postings from August 2012

Fwd: [perl.git] branch yves/superfasthash3, updated. v5.17.3-161-g764c390

Thread Next
From:
demerphq
Date:
August 28, 2012 02:18
Subject:
Fwd: [perl.git] branch yves/superfasthash3, updated. v5.17.3-161-g764c390
Message ID:
CANgJU+UDmVcVGqjoyEfE0cmGfp7y_=5+cW3CuX7YyQqoVivPCw@mail.gmail.com
Whatever happens to the hash randomization and alternate hash function
branch this patch should be cherry picked.

Yves


---------- Forwarded message ----------
From: Yves Orton <demerphq@gmail.com>
Date: 28 August 2012 11:15
Subject: [perl.git]  branch yves/superfasthash3, updated. v5.17.3-161-g764c390
To: perl5-changes@perl.org


In perl.git, the branch yves/superfasthash3 has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/764c3906d44c5575dd28fb8ef2eb1eb5753597da?hp=b8ceec11974e524e63ce2c01b5f0d3b9104b26d9>

- Log -----------------------------------------------------------------
commit 764c3906d44c5575dd28fb8ef2eb1eb5753597da
Author: Yves Orton <demerphq@gmail.com>
Date:   Tue Aug 28 11:07:18 2012 +0200

    fix off-by-one error in uninitialized warnings subscript finding logic

    When we use an uninitialized var in a hash we try to find the var, so
    we can show the subscript. An off by one error prevented us from seeing
    the items in the last bucket.

    We expect to see this:

       $ ./perl -Ilib -MDevel::Peek -wle'our
%foo7=("foo"=>"bar","baz"=>undef); \
       $SIG{__WARN__}=sub { print STDERR @_; Dump(\%foo7); }; print
sprintf "\n%s:%s %s:%s",%foo7;'

       Use of uninitialized value $foo7{"baz"} in sprintf at -e line 1.

    But when baz was stored in the last bucket (1/8th of the time) it fails
    to find it:

       $ ./perl -Ilib -MDevel::Peek -wle'our
%foo7=("foo"=>"bar","baz"=>undef); \
       $SIG{__WARN__}=sub { print STDERR @_; Dump(\%foo7); }; print
sprintf "\n%s:%s %s:%s",%foo7;'

       Use of uninitialized value within %foo7 in sprintf at -e line 1.

    This patch fixes the off by one error. It does not correct any broken
    tests it might cause. I will do that in a follow up patch.
-----------------------------------------------------------------------

Summary of changes:
 sv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sv.c b/sv.c
index e233f54..a1167a1 100644
--- a/sv.c
+++ b/sv.c
@@ -13822,7 +13822,7 @@ S_find_hash_subscript(pTHX_ const HV *const
hv, const SV *const val)

     array = HvARRAY(hv);

-    for (i=HvMAX(hv); i>0; i--) {
+    for (i=HvMAX(hv); i>=0; i--) {
        HE *entry;
        for (entry = array[i]; entry; entry = HeNEXT(entry)) {
            if (HeVAL(entry) != val)

--
Perl5 Master Repository


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About