I'm not sure why this happens, but the hash_lan function in ipmi_lan.c,
when compiled in 64-bit mode, sometimes returns negative numbers, which
results in a segfault inside the library.  I suspect the games it's
playing with pointer math aren't exactly 64-bit clean.  Adding an
operation to mask the index value to 31 bits after the shift and before
the modulo operation clears this up.  I doubt it will seriously affect
the output of the hash function, since the mask operation is masking off
bits that "should" be removed by the modulo operation anyway.

This problem has existed at least as far back as OpenIPMI 2.0.10, where
I first noticed it.  When we recently upgraded the version of OpenIPMI
we use to 2.0.14, this problem reared its ugly head again.  Hopefully, I
can get this fix in the mainline code and we'll never have to worry
about it again.

diff -Naur OpenIPMI-2.0.14-ORIGINAL/lib/ipmi_lan.c
OpenIPMI-2.0.14/lib/ipmi_lan.c
--- OpenIPMI-2.0.14-ORIGINAL/lib/ipmi_lan.c     2007-10-16
11:46:15.000000000 -0600
+++ OpenIPMI-2.0.14/lib/ipmi_lan.c      2008-11-17 10:48:51.000000000
-0700
@@ -1352,6 +1352,8 @@

     idx = (((unsigned long) ipmi)
           >> (sizeof(unsigned long) >> LAN_HASH_SHIFT));
+    /* sometimes 64-bit pointer math gets in the way, mask to 31 bits
*/
+    idx &= 0x7FFFFFFF;
     idx %= LAN_HASH_SIZE;
     return idx;
 }

-- 
Eric J. Bowersox, Software Engineer     Aspen Systems, Inc.
<[EMAIL PROTECTED]>                      3900 Youngfield Street
Tel: +01 303 431 4606 x113              Wheat Ridge, CO  80033, USA
Fax: +01 303 431 7196                   <http://www.aspsys.com>

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Openipmi-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to