FreeBSD Port: id-utils-3.2d - classify_link function casues SIGSEGV
in CYGWIN
Madhu Gogulapati
madhu_gogulapati at hotmail.com
Wed Feb 25 15:23:46 PST 2004
Hi:
In cygwin environment, after configuring and compiling, all the id-utils
except mkid are failing SIGSEGV [Segmentation fault (core dumped)]. The
problem seems to be fixed by removing the if condition of file size check
for 0 in function "classify_link" function.
Pratyusha at pratyusha ~/id-utils-3.2d
$ bash --version
GNU bash, version 2.05b.0(1)-release (i686-pc-cygwin)
Copyright (C) 2002 Free Software Foundation, Inc.
Pratyusha at pratyusha ~/id-utils-3.2d
$ gcc --version
gcc (GCC) 3.3.1 (cygming special)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Pratyusha at pratyusha ~/id-utils-3.2d
$ src/mkid --version
src/mkid - GNU id-utils 3.2d
Pratyusha at pratyusha ~/id-utils-3.2d
$ src/fnid --version
src/fnid - GNU id-utils 3.2d
Pratyusha at pratyusha ~/id-utils-3.2d
$ src/fnid
Segmentation fault (core dumped)
Pratyusha at pratyusha ~/id-utils-3.2d
$
PROBLEM DETAILS & WORK AROUND FOLLOWS:
The gdb dump shows following trace:
-------------------------------------------
Pratyusha at pratyusha ~/id-utils-3.2d
$ gdb src/fnid
GNU gdb 2003-09-20-cvs (cygwin-special)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb)
(gdb) where
No stack.
(gdb) run
Starting program: /home/Pratyusha/id-utils-3.2d/src/fnid.exe
Program received signal SIGSEGV, Segmentation fault.
0x00403bfc in deserialize_file_links (idhp=0x40b920) at idread.c:113
113 flink->fl_parent = flinks_0[parent_index];
(gdb) where
#0 0x00403bfc in deserialize_file_links (idhp=0x40b920) at idread.c:113
#1 0x004038be in read_id_file (id_file_name=0x4040db "ID", idhp=0x40b920)
at idread.c:42
#2 0x004014d3 in main (argc=4199222, argv=0x4010f0) at fnid.c:155
(gdb)
105 c = getc (idhp->idh_FILE);
106 obstack_1grow (&idhp->idh_file_link_obstack, c);
107 }
108 while (c);
109 flink = (struct file_link *) obstack_finish
(&idhp->idh_file_link_obstack);
110 *flinks = flink;
111 io_read (idhp->idh_FILE, &flink->fl_flags, sizeof
(flink->fl_flags), IO_TYPE_INT);
112 io_read (idhp->idh_FILE, &parent_index, FL_PARENT_INDEX_BYTES,
IO_TYPE_INT);
113 flink->fl_parent = flinks_0[parent_index];
114 slot = (struct file_link **) hash_find_slot
(&idhp->idh_file_link_table, flink);
(gdb)
(gdb) print flink
$1 = (struct file_link *) 0x10074ad8
(gdb) print *flink
$2 = {fl_u = {u_parent = 0x10074ad8, u_index = 268913368}, fl_flags = 34
'"', fl_name = "P"}
(gdb) print *flinks_0[0]
$3 = {fl_u = {u_parent = 0x10012ab8, u_index = 268511928}, fl_flags = 34
'"', fl_name = "/"}
(gdb) print *flinks_0[1]
$4 = {fl_u = {u_parent = 0x10074ad8, u_index = 268913368}, fl_flags = 34
'"', fl_name = "P"}
(gdb) print *flinks_0[2]
Cannot access memory at address 0x0
(gdb) printf "%s\n", flinks_0[0]->fl_name
/
(gdb) printf "%s\n", flinks_0[1]->fl_name
Pratyusha
(gdb)print parent_index
$5 = 70288
(gdb) print **slot
$9 = {fl_u = {u_parent = 0x10012ab8, u_index = 268511928}, fl_flags = 34
'"', fl_name = "/"}
-------------------------------------------
The problem seems happening due to Greg changes in libidu/walker.c file:
(classify_link): Return 0 if file size is zero.
In cygwin enviroment, for to be some of directory entries in cygwin seems to
have size of 0, as shown below [/home, /sbin, /tmp & /home/Administrator
directories]:
--------------------------------------------
Pratyusha at pratyusha ~/id-utils-3.2d
$ ls -lrt /
total 8
drwxrwxrwx+ 2 Administ Users 0 Feb 23 05:05 sbin
drwxrwxrwx+ 21 Administ Users 4096 Feb 23 06:06 usr
drwxrwxrwx+ 11 Administ Users 4096 Feb 23 06:13 var
drwxrwxrwx+ 37 Administ Users 86016 Feb 23 06:14 lib
drwxrwxrwx+ 4 Administ Users 282624 Feb 23 06:15 bin
drwxrwxrwx+ 25 Administ Users 16384 Feb 23 06:15 etc
-rwxrwxrwx 1 Administ Users 7022 Feb 23 07:26 cygwin.ico
-rwxrwxrwx 1 Administ Users 64 Feb 23 07:26 cygwin.bat
drwxrwxrwx+ 4 Administ None 0 Feb 23 09:58 home
drwxrwxrwx+ 3 Administ Users 0 Feb 25 15:05 tmp
Pratyusha at pratyusha ~/id-utils-3.2d
$ ls -rlt /home
total 0
drwxrwxrwx+ 4 Administ None 0 Feb 23 07:29 Administrator
drwxrwxrwx+ 6 Pratyush None 4096 Feb 25 14:33 Pratyusha
Pratyusha at pratyusha ~/id-utils-3.2d
--------------------------------------------
--------------------------------------------
$ diff -c libidu/walker_org.c libidu/walker.c
*** libidu/walker_org.c Tue Apr 6 01:17:29 1999
--- libidu/walker.c Wed Feb 25 13:18:18 2004
***************
*** 725,733 ****
--- 725,736 ----
flags |= FL_SYM_LINK;
}
#endif
+ /* Comment out the changes mad by Greg McGary 1999-04-06
if (stp->st_size == 0)
return 0;
else if (S_ISDIR (stp->st_mode))
+ */
+ if (S_ISDIR (stp->st_mode))
flags |= FL_TYPE_DIR;
else if (S_ISREG (stp->st_mode))
flags |= FL_TYPE_FILE;
-------------------------------------
Regards,
Madhu Gogulapati
Email: Madhu_Gogulapati at HotMail.com
_________________________________________________________________
Stay informed on Election 2004 and the race to Super Tuesday.
http://special.msn.com/msn/election2004.armx
More information about the freebsd-ports
mailing list