public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/6966] New: hsearch almost always probes the same index when using the secondary hash
@ 2008-10-19  1:30 bugzilla at bsb dot me dot uk
  2008-10-19  1:34 ` [Bug libc/6966] " bugzilla at bsb dot me dot uk
  2008-11-01 15:39 ` drepper at redhat dot com
  0 siblings, 2 replies; 4+ messages in thread
From: bugzilla at bsb dot me dot uk @ 2008-10-19  1:30 UTC (permalink / raw)
  To: glibc-bugs

hsearch references Kunth vol. 3 6.4 on "open addressing" but the code does
implement the algorithm from Knuth.  Instead of generating the second hash from
the first, the code generates the second hash from the first index.  Because
this hash is then used to step the index, the result is that the first index
generated is (almost) always the same.

This partly defeats the purpose of using a secondary hash.

I say "almost" because it happens for all but 2 of the possible index values in
any given table.  For example, in a table of size 11, all secondary probes will
start at index 10 unless the inital hash produced 9 or 10.

This was reported on news:comp.lang.c by James Dow Allen and I decided to check
on it.  I have a simple patch but I am not sure of the procedure for posting
patches to glibc.

-- 
           Summary: hsearch almost always probes the same index when using
                    the secondary hash
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: minor
          Priority: P3
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bugzilla at bsb dot me dot uk
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=6966

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <bug-6966-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2014-07-02  6:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-19  1:30 [Bug libc/6966] New: hsearch almost always probes the same index when using the secondary hash bugzilla at bsb dot me dot uk
2008-10-19  1:34 ` [Bug libc/6966] " bugzilla at bsb dot me dot uk
2008-11-01 15:39 ` drepper at redhat dot com
     [not found] <bug-6966-131@http.sourceware.org/bugzilla/>
2014-07-02  6:15 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).