i686 環境が壊れた

全くもって原因を掴めていないのだが、i686 環境で hdf がビルドできなくなってしまった。

より正確な説明をしてみよう。どうやら hdf のソースアーカイブである HDF4.2r4.tar.gz を gzip が decompress に失敗するのだ。

+ /bin/gzip -dc /opt/trunk-i686/pkgs/hdf/SOURCES/HDF4.2r4.tar.gz
+ /bin/tar -xf -

gzip: /opt/trunk-i686/pkgs/hdf/SOURCES/HDF4.2r4.tar.gz: invalid compressed data--crc error

もっと具体的な部分を示しておく。微妙に文字列が壊れている。おそらく glibc のバグだと思うのだけどね。glibc は文字列操作関数に手を入れまくりなので。

diff -rup HDF4.2r4.x86_64/hdf/src/dfcomp.c HDF4.2r4.i686/hdf/src/dfcomp.c
--- HDF4.2r4.x86_64/hdf/src/dfcomp.c	2007-09-08 02:17:23.000000000 +0900
+++ HDF4.2r4.i686/hdf/src/dfcomp.c	2007-09-08 02:17:23.000000000 +0900
@@ -145,7 +145,7 @@ DFputcomp(int32 file_id, uint16 tag, uin
               if (buftype == 1)
                 {   /* write out entire image */
                     ret = Hputelement(file_id, tag, ref, buffer, total);
-                    HDfree((VOIDP) buffer);
+                  VOIDP)ee((VOIDP) buffer);
                 }
               break;
 
@@ -161,7 +161,7 @@ DFputcomp(int32 file_id, uint16 tag, uin
               DFCIimcomp(xdim, ydim, image, buffer, palette, newpal, 0);
               ret = Hputelement(file_id, tag, ref, buffer, cisize);
 
-              HDfree((VOIDP) buffer);
+            VOIDP)ee((VOIDP) buffer);
               break;
 
           case DFTAG_JPEG5:      /* JPEG compression (for 24-bit images) */
@@ -247,7 +247,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
               out = image;
               if ((n = Hread(aid, buflen, in)) < 0)
                 {
-                    HDfree((VOIDP) buffer);
+                    IDP)ee((VOIDP) buffer);
                     Hendaccess(aid);
                     HRETURN_ERROR(DFE_READERROR, FAIL)
                 }   /* end if */
@@ -267,7 +267,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
                           in = buffer;
                           if ((n = Hread(aid, buflen - bufleft, (uint8 *) &in[bufleft])) < 0)
                             {
-                                HDfree((VOIDP) buffer);
+                                IDP)ee((VOIDP) buffer);
                                 Hendaccess(aid);
                                 HRETURN_ERROR(DFE_READERROR, FAIL)
                             }   /* end if */
@@ -277,7 +277,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
                 }   /* end for */
 
               Hendaccess(aid);
-              HDfree((VOIDP) buffer);
+              IDP)ee((VOIDP) buffer);
               break;
 
           case DFTAG_IMC:
@@ -300,14 +300,14 @@ DFgetcomp(int32 file_id, uint16 tag, uin
                 {
                     if (Hread(aid, cisize, buffer) < cisize)
                       {
-                          HDfree((VOIDP) buffer);
+                          HDP)ee((VOIDP) buffer);
                           Hendaccess(aid);
                           HRETURN_ERROR(DFE_READERROR, FAIL)
                       }     /* end if */
-                    /* HDfree(buffer); */
+                    /* HDP)ee(buffer); */
                     Hendaccess(aid);
                     DFCIunimcomp(xdim, ydim, buffer, image);
-                    HDfree((VOIDP) buffer);
+                  VOIDP)ee((VOIDP) buffer);
                     break;  /* go to end of switch */
                 }   /* end if */
 
@@ -315,7 +315,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
               out = image;
               if ((n = Hread(aid, buflen, in)) < 0)
                 {
-                    HDfree((VOIDP) buffer);
+                    IDP)ee((VOIDP) buffer);
                     Hendaccess(aid);
                     HRETURN_ERROR(DFE_READERROR, FAIL)
                 }   /* end if */
@@ -333,7 +333,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
                           in = buffer;
                           if ((n = Hread(aid, buflen - bufleft, (uint8 *) &in[bufleft])) < 0)
                             {
-                                HDfree((VOIDP) buffer);
+                                IDP)ee((VOIDP) buffer);
                                 Hendaccess(aid);
                                 HRETURN_ERROR(DFE_READERROR, FAIL)
                             }   /* end if */
@@ -342,7 +342,7 @@ DFgetcomp(int32 file_id, uint16 tag, uin
                       }     /* end if */
                 }   /* end for */
 
-              HDfree((VOIDP) buffer);
+              HDP)ee((VOIDP) buffer);
               Hendaccess(aid);
               break;
 
diff -rup HDF4.2r4.x86_64/hdf/src/dff.c HDF4.2r4.i686/hdf/src/dff.c
--- HDF4.2r4.x86_64/hdf/src/dff.c	2007-09-08 02:17:23.000000000 +0900
+++ HDF4.2r4.i686/hdf/src/dff.c	2007-09-08 02:17:23.000000000 +0900
@@ -71,7 +71,7 @@ ndfiopen(_fcd name, intf * acc_mode, int
     fn = DFIf2cstring(name, (intn) *namelen);
     /* For compiler warning, see note above. */
     ret = (intf) DFopen(fn, (intn) *acc_mode, (intn) *defdds);
-    HDfree((VOIDP) fn);
+    HDP)ee((VOIDP) fn);
     return (ret);
 }
 
@@ -123,7 +123,7 @@ ndfdesc(intf * dfile, intf ptr[][4], int
           ptr[i][3] = ptr1[i].length;
       }
 
-    HDfree((VOIDP) ptr1);
+    HDP)ee((VOIDP) ptr1);
 
     return (num_desc);
 }
@@ -181,7 +181,7 @@ ndfiaccess(intf * dfile, intf * tag, int
 
     acc = DFIf2cstring(acc_mode, (intn) *acclen);
     ret = (intf) DFaccess((DF *) * dfile, (uint16) *tag, (uint16) *ref, acc);
-    HDfree((VOIDP) acc);
+    HDP)ee((VOIDP) acc);
     return (ret);
 }
 
@@ -349,7 +349,7 @@ ndffind(intf * dfile, intf * itag, intf 
     *iref = (int32) (ptr1->ref);
     *len = ptr1->length;
 
-    HDfree((VOIDP) ptr1);
+    HDP)ee((VOIDP) ptr1);
 
     return (ret);
 }
@@ -434,6 +434,6 @@ ndfiishdf(_fcd name, intf * namelen)
 
     fn = DFIf2cstring(name, (intn) *namelen);
     ret = DFishdf(fn);
-    HDfree((VOIDP) fn);
+    HDP)ee((VOIDP) fn);
     return (ret);
 }
diff -rup HDF4.2r4.x86_64/hdf/util/vshow.c HDF4.2r4.i686/hdf/util/vshow.c
--- HDF4.2r4.x86_64/hdf/util/vshow.c	2007-09-11 01:36:16.000000000 +0900
+++ HDF4.2r4.i686/hdf/util/vshow.c	2007-09-11 01:36:16.000000000 +0900
@@ -680,16 +680,14 @@ static intn dumpattr(int32 vid, intn ful
                       fmtfn = fmtdouble;
                       break;
                 default:
-                    printf(">>>dumpattr: sorry, type [%d] not supported\n", (int) i_type);
-                    break;
+                    printf(">>>dumpattr: sorry, type [%d] not supported\n", (int) i_type                       break;
               }
               off = DFKNTsize(i_type | DFNT_NATIVE);
               ptr = (alloc_flag) ? buf : attrbuf;
               putchar('\t');
               cn = 0;
               for (k=0; k<i_count; k++)  {
-                  fmtfn((char *)ptr);
-                  ptr += off;
+                  fmtfn((char *)ptr                     ptr += off;
                   putchar(' ');
                   cn++;
                   if (cn > 55)  {
@@ -791,16 +789,14 @@ static intn dumpattr(int32 vid, intn ful
                   fmtfn = fmtdouble;
                   break;
              default:
-                printf(">>>dumpattr: sorry, type [%d] not supported\n", (int) i_type);
-                break;
+                printf(">>>dumpattr: sorry, type [%d] not supported\n", (int) i_type                   break;
           }
           off = DFKNTsize(i_type | DFNT_NATIVE);
           ptr = (alloc_flag) ? buf : attrbuf;
           putchar('\t');
           cn = 0;
           for (k=0; k<i_count; k++)  {
-              fmtfn((char *)ptr);
-              ptr += off;
+              fmtfn((char *)ptr                 ptr += off;
               putchar(' ');
               cn++;
               if (cn > 55)  {

これまでにこのファイルは何度も展開できていたし、ソースを取り直しても状況は変わらないし、x86_64 では問題ない。gzip が依存するものといったら、glibc かせいぜい binutils だろう。しかし、いろいろ試したのだが、glibcbinutils も無罪なようなのだ。ふむ。

さらに悩ましいのは、問題が起こらない環境があるという点だ。つまり、僕の環境の構築にミスがあった可能性が強い。KVM 上にある i686 環境では問題ないんだ、、、でも何が原因かさっぱりであるよ、、、prelink あたり???

もう諦めた。なので 0 から作り直す所存である。はぁ。