[devel] Fwd: Hash seed breaks 5.8.1 binary API; fix suggested

Alexey Tourbin =?iso-8859-1?q?at_=CE=C1_altlinux=2Eru?=
Пт Окт 10 16:04:31 MSD 2003


Не знаю пока что делать. :(

----- Forwarded message from Chip Salzenberg <chip на pobox.com> -----

Date: Thu, 9 Oct 2003 22:41:34 -0400
From: Chip Salzenberg <chip на pobox.com>
Subject: Hash seed breaks 5.8.1 binary API; fix suggested
To: Perl 5 Porters <perl5-porters на perl.org>
Cc: debian-perl на lists.debian.org
User-Agent: Mutt/1.5.4i

I've found (with Walt Mankowski's help[*]) the probable explanation for
why some modules -- most notably HTML::Parser -- break when Perl is
upgraded from 5.8.0 to 5.8.1.  The hash seeding implementation has
broken the binary API.  (Walt had the presence of mind to test with
PERL_HASH_SEED=0 and found that it fixed the breakage.)

Note that I say 5.8.1 broke the *binary* API.  The *source* API is
compatible, which is why rebuilding HTML::Parser fixes the problems.

The problem originates in the placement of the code to add the seed to
the hash.  The traditional (unchanged) hash value should have been
passed as always to the functions that expect it (e.g. hv_fetch_ent()),
but instead it was made a part of the PERL_HASH() macro.  Essentially
the binary API changed - functions that used to expect a hash based on
a string now expect a hash based on a string plus a global variable
that didn't even exist before 5.8.1.

I suggest we fix this problem in 5.8.2 (which should be released
quickly) in the following fashion:

  1. Decree that PL_hash_seed should forever and ever be zero.
     This will make 5.8.0 and 5.8.1 PERL_HASH() calculate the same
     value at all times.

  2. Create a new variable PL_new_hash_seed which is initialized with
     the methods currently used for PL_hash_seed.

  3. Add (or xor or whatever) PL_new_hash_seed with the user-provided
     hash value *inside* the functions that use hashes, *not* outside
     them.

These changes should make 5.8.2 both source and binary compatible with
both 5.8.0. and 5.8.1.
-- 
Chip Salzenberg               - a.k.a. -               <chip на pobox.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
    but he stepped in a wormhole and had to go in early."  // MST3K

----- End forwarded message -----
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Тип     : application/pgp-signature
Размер  : 189 байтов
Описание: =?iso-8859-1?q?=CF=D4=D3=D5=D4=D3=D4=D7=D5=C5=D4?=
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20031010/98e2bb1c/attachment-0001.bin>


Подробная информация о списке рассылки Devel