bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

readdir d_type bug causes probrems.


From: Gemma Teruaki
Subject: readdir d_type bug causes probrems.
Date: Thu, 21 Aug 2003 20:04:21 +0900

Gtags-4.6 doesn't work correctry in my linux box (using libc-2.2.5).
It always outputs zero-size GRTAGS and GTAGS.

I think that the cause would be the readdir(3) d_type bug.
"BUGS Field d_type is not implemented as of libc6 2.0.4 and will always
return 0(unknown)."

In my linux box, 
1. "unsigned char d_type;" exists in "struct dirent{};". 
   See "/usr/include/dirent.h".
2. so HAVE_DP_D_TYPE is defined.
3. but d_type always return 0. 
4. strbuf_value(curp->sb) returns " const.h" but it should be 
   "fconst.h", I think. See gdb log.

find.c:440
curp->sb = strbuf_open(0);
if (getdirs(dir, curp->sb) < 0)
        die("cannot open '.' directory.");
curp->start = curp->p = strbuf_value(curp->sb);

5. Manually undefining HAVE_DP_D_TYPE solved my problem, that is, 
   "lstat" method was good for me.  

<CONTENTS /usr/include/dirent.h>
#include <bits/dirent.h>
</CONTENTS /usr/include/dirent.h>
<CONTENTS /usr/include/bits/dirent.h>
struct dirent
  {
#ifndef __USE_FILE_OFFSET64
    __ino_t d_ino;
    __off_t d_off;
#else
    __ino64_t d_ino;
    __off64_t d_off;
#endif
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];           /* We must not include limits.h! */
  };

#undef  _DIRENT_HAVE_D_NAMLEN
#define _DIRENT_HAVE_D_RECLEN
#define _DIRENT_HAVE_D_OFF
#define _DIRENT_HAVE_D_TYPE
</CONTENTS /usr/include/bits/dirent.h>

$ ls
Makefile     Makefile.in  gtags    gtags.c  manual.in
Makefile.am  const.h      gtags.1  gtags.o

Current directory is /home/teruaki/global-4.6/gtags/
GNU gdb 5.2.1
(gdb) break getdirs
Breakpoint 1 at 0x804da0d: file find.c, line 352.
(gdb) break find.c:440
Breakpoint 2 at 0x804dc92: file find.c, line 440.
(gdb) run
Starting program: /home/teruaki/global-4.6/gtags/gtags 

Breakpoint 1, getdirs (dir=0x8063f40 ".", sb=0x8063f40) at find.c:352
(gdb) display *dp
1: *dp = {d_ino = 1836017711, d_off = 1702113125, d_reclen = 30066, 
  d_type = 97 'a', d_name = "ki/global-4.6/gtags", '\0' <repeats 236 times>}
(gdb) next
1: *dp = {d_ino = 72505, d_off = 2, d_reclen = 16, d_type = 0 '\0', 
  d_name = ".\0\0\0\0q\032\001\0\0Bカ\005\020\0\0..\0\0\0>\e\001\0\200ロQ
\b\030\0\0const.h\0\0\0\0\0\0f\e\001\0\0tB \b\030\0\0Makefile\0\0\0\0\0
\214\e\001\0\0r(\f\030\0\0.deps\0\0\0\0\0\0\0\0ニ\e\001\0\200c6\f\030\0\
0GPATH\0\0\0\0\0\0\0\0タ\e\001\0\200ムツ」\021\030\0\0GTAGS\0\0\0\0\0\0\0\0
h2\001\0\0rBャA\030\0\0gtags\0\0\0\0\0\0\0\0:\e\001\0\0/ュA\030\0\0Makefi
le.am\0\0;\e\001\0\200\212oV\030\0\0"...}
(gdb) next 
1: *dp = {d_ino = 72305, d_off = 95830528, d_reclen = 16, d_type = 0
'\0',   d_name = "..\0\0\0>\e\001\0\200ロQ\b\030\0\0const.h\0\0\0\0\0\0f
\e\001\0 \0tB \b\030\0\0Makefile\0\0\0\0\0\214\e\001\0\0r(\f\030\0\0.de
ps\0\0\0\0\0\0\0\0ニ\e\001\0\200c6\f\030\0\0GPATH\0\0\0\0\0\0\0\0タ\e\001
\0\200ムツ」\021\030\0\0GTAG S\0\0\0\0\0\0\0\0h2\001\0\0rBャA\030\0\0gtags\
0\0\0\0\0\0\0\0:\e\001\0\0/ュA\030\0\0Makefile.am\0\0;\e\001\0\200\212oV
\030\0\0Makefile.in\0\0=\e\001"...}
(gdb) next
1: *dp = {d_ino = 72510, d_off = 139582336, d_reclen = 24, d_type = 0 '\0', 
  d_name = "const.h\0\0\0\0\0\0f\e\001\0\0tB \b\030\0\0Makefile\0\0\0\0\
0\214\e\001\0\0r(\f\030\0\0.deps\0\0\0\0\0\0\0\0ニ\e\001\0\200c6\f\030\0\
0GPATH\0\0\0\0\0\0\0\0タ\e\001\0\200ムツ」\021\030\0\0GTAGS\0\0\0\0\0\0\0\0h
2\001\0\0rBャA\030\0\0gtags\0\0\0\0\0\0\0\0:\e\001\0\0/ュA\030\0\0Makefile
.am\0\0;\e\001\0\200\212oV\030\0\0Makefile.in\0\0=\e\001\0\0ュoV\030\0\0g
tags.1\0"...}
(gdb) next
1: *dp = {d_ino = 72550, d_off = 144765952, d_reclen = 24, d_type = 0 '\0', 
  d_name = "Makefile\0\0\0\0\0\214\e\001\0\0r(\f\030\0\0.deps\0\0\0\0\0\0
\0\0ニ\e\001\0\200c6\f\030\0\0GPATH\0\0\0\0\0\0\0\0タ\e\001\0\200ムツ」\021\03
0\0\0GTAGS\0\0\0\0\0\0\0\0h2\001\0\0rBャA\030\0\0gtags\0\0\0\0\0\0\0\0:\e\
001\0\0/ュA\030\0\0Makefile.am\0\0; \e\001\0\200\212oV\030\0\0Makefile.in\
0\0=\e\001\0\0ュoV\030\0\0gtags.1\0\0\0\0\0\0<\e\001\0\200オoV\030\0\0gtags
.c\0"...}
(gdb) continue
Continuing.

Breakpoint 2, find_open (start=0x8077bff "") at find.c:444
(gdb) print *curp
$1 = {sb = 0x806b840, dirp = 0x8063f41 "", start = 0x8077b90 " const.h", 
  end = 0x8077bff "", p = 0x8077b90 " const.h"}
(gdb) quit

-- 
Gemma Teruaki <address@hidden>









reply via email to

[Prev in Thread] Current Thread [Next in Thread]