#20 Updatedb falls into endless loop in filesystem
Opened by jklaverstijn. Modified

I have a file with the same inode number as its containing directory. This is a supposedly illegal situation for Ext4 but it can occur. Many commands detect the situation and throw an error. Updatedb however goes into the recursion loop and eventually crashes. This leaves the intermediate /var/lib/mlocate. When run from cron this can eventually fill up the filesystem.

I suggest locatedb also detects the problem and deals with it elegantly. I lack skills and time to write a patch but hope my findings can help improve this program. locate is in my top 5 admin commands. Use it daily.


Thanks for your report. As you say, a directory contained in itself is invalid.

I'm somewhat reluctant to add safeguards against invalid situations to mlocate because there are too many invalid situations, and a program can't ever expect to behave correctly in all invalid situations. (On the other hand, some "invalid situations" unfortunately do occur frequently enough that they had to be handled.)

That said, perhaps there is something easy that could be done to improve the situation. In particular, from a quick look I think that if the only problem in the filesystem is a single nested directory, I'd expect the nested recursion to silently terminate at level around 1024, when file descriptors run out (compare output of (ulimit -n)), and go on indexing the rest of the file system, without crashing.

Can you still reproduce the problem?

If not, do you have any data that could help debug the problem, e.g. error messages, backtraces, core files, or at least complete output of updatedb with the -v option added?

Metadata