tech-toolchain archive

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

awk infinite loop from maketars/getdirs



Hi,

With recent makemandb changes, i noticed that the build process never
finish with MKDEBUG set to yes. I tracked it to nbawk stuck in an
infinite loop when creating set.comp ...

[...]
DEBUG: list_set_files: ./lists/comp/mi
DEBUG: list_set_files: ./lists/comp/md.amd64
DEBUG: list_set_files: ./lists/comp/stl.mi
DEBUG: list_set_files: ./lists/comp/shl.mi
+ '[' '!' -s '/tmp/maketars.11476a/flist.comp' ']'
+ '[' -n '/local/src/NetBSD/dest/amd64/METALOG.sanitised' ']'
+ true
+ msg 'Creating /local/src/NetBSD/dest/amd64/etc/mtree/set.comp'
+ false
+ echo Creating '/local/src/NetBSD/dest/amd64/etc/mtree/set.comp'
Creating /local/src/NetBSD/dest/amd64/etc/mtree/set.comp
+ /local/src/NetBSD/tool/bin/nbawk -f './getdirs.awk' 
'/tmp/maketars.11476a/flist.comp'
[...LOOP...]

Looking at the flist.comp data, i discovered that the offending line
show 2 consecutive slashes :

njoly@lanfeust [distrib/sets]> grep '\/\/' '/tmp/maketars.11476a/flist.comp'
./usr/libdata/debug/usr/sbin//makemandb.debug

When parsing the directory tree for this line, the dirname() func
remove only one of the two '/' character with the file name, and then
loops. But at that time, dirname() gsub call fails to match anything
and return the input string unmodified, and it loops again... forever.

The attached patch fix this issue by making dirname() gsub call kill
all slashes before the name, not only the last one.

Does it looks ok ?

Thanks.

-- 
Nicolas Joly

Projects and Developments in Bioinformatics
Institut Pasteur, Paris.
Index: distrib/sets/getdirs.awk
===================================================================
RCS file: /cvsroot/src/distrib/sets/getdirs.awk,v
retrieving revision 1.4
diff -u -p -r1.4 getdirs.awk
--- distrib/sets/getdirs.awk    30 Apr 2008 13:10:49 -0000      1.4
+++ distrib/sets/getdirs.awk    8 Feb 2012 14:26:35 -0000
@@ -32,7 +32,7 @@
 function dirname(file) \
 {
        # no need to worry about args that do not contain at least one "/"
-       gsub(/\/[^\/]+$/, "", file)
+       gsub(/\/+[^\/]+$/, "", file)
        return file
 }
 


Home | Main Index | Thread Index | Old Index