From: Peter Barada <peter.barada@logicpd.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Hash problem...
Date: Mon, 17 Jan 2011 17:53:18 -0500 [thread overview]
Message-ID: <4D34C85E.4030408@logicpd.com> (raw)
I've stumbled across a problem in U-boot 2010.12's hashing algorithm.
In my particular case the size of the has table is 347 (due to my
default environment being 2258 bytes long as reported on entry to
himport_r), and I have in my envrironment the variable "ramdiskimage" as
well as "preboot"; part of my startup is to do some housecleaning then
delete preboot so its only done once. But when I load u-boot with an
empty environemnt environment, I see the following problem:
...
=> printenv
....
ramdiskimage=rootfs.ext2.gz.uboot
....
=> echo $ramdiskimage
=> setenv ramdiskimage=rootfs.ext2.gz.uboot
=> printenv
...
ramdiskimage=rootfs.ext2.gz.uboot
ramdiskimage=rootfs.ext2.gz.uboot
...
After spending an entire day digging into the hash using GDB/BDI on my
ARM board, I've findally figured out that the hash key of "ramdiskimage"
and "preboot" are the same modulus 347, and this is problematic because
on the initial hash import, preboot is placed into the hash first (at
idx 190 since the table is sorted), and then ramdiskimage collides with
preboot causing the 2nd probe (at idx 191) to occur which works fine.
Unfortunately as part of the housecleaning, preboot is deleted and the
environemnt saved. The delete of preboot removes entry at idx 190 and
the next lookup of ramdiskimage sees that idx 190 is empty and believes
that the ramdiskimage is not in the table ionstead of rehashing to find
it at idx 191.
The hash delete code is in error; instead of just removing the deleted
key, it should instead allocate a new hashtable, hash all the keys into
the new table except for the deleted key and then reclaim the old table
(and deleted key).
--
Peter Barada
peter.barada at logicpd.com
next reply other threads:[~2011-01-17 22:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 22:53 Peter Barada [this message]
2011-01-19 8:32 ` [U-Boot] Hash problem Wolfgang Denk
2011-01-19 16:32 ` [U-Boot] [Patch] Fix hash table deletion to prevent lost entries Peter Barada
2011-01-19 20:47 ` Wolfgang Denk
2011-01-20 15:53 ` [U-Boot] [Patch v2] " Peter Barada
2011-03-21 21:48 ` Wolfgang Denk
2011-03-21 23:05 ` Peter Barada
2011-03-22 21:45 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D34C85E.4030408@logicpd.com \
--to=peter.barada@logicpd.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox