Norbert Schuch wrote:
Hi,


Dirk Heinrichs-2 wrote:
I'm currently facing strange behaviour on one client machine, which looks like:

[...]
[EMAIL PROTECTED] ~ % LANG="" ll /afs/altum.de
ls: cannot access /afs/altum.de/music: No such file or directory


I had the same problem after compiling a new kernel. However, I have discovered meanwhile that it is caused by the gcc version used: The 2.6.21.1 to 2.6.21.7 kernels all do NOT work with openafs-1.4.4 when compiled with gcc-4.2 (although both compile, and the driver is loaded -- only the afs cannot be accessed), whereas they work if compiled with gcc-4.0.


Regards,
Norbert

Anyone care to test out the attached patch for src/dir/dir.c

The hashing code in the DirHash() function relies on integer overflow to make the hval value turn into a negative value. gcc 4.2 assumes that this value can never go negative and optimizes out the (hval < 0) test.

Marc

Index: src/dir/dir.c
===================================================================
RCS file: /cvs/openafs/src/dir/dir.c,v
retrieving revision 1.24
diff -u -r1.24 dir.c
--- src/dir/dir.c       13 Oct 2005 15:12:12 -0000      1.24
+++ src/dir/dir.c       7 Oct 2007 17:10:37 -0000
@@ -478,8 +478,9 @@
 {
     /* Hash a string to a number between 0 and NHASHENT. */
     register unsigned char tc;
-    register int hval;
+    unsigned long hval;
     register int tval;
+
     hval = 0;
     while ((tc = (*string++))) {
        hval *= 173;
@@ -488,7 +489,7 @@
     tval = hval & (NHASHENT - 1);
     if (tval == 0)
        return tval;
-    else if (hval < 0)
+    else if (hval >= 1<<31)
        tval = NHASHENT - tval;
     return tval;
 }

Reply via email to