0.99.1 Linux: Searching similar files traverses symlinks to other folders some times causing infinite path recursion

Bugs which have been reproduced by a second user or the developer, or features to do

Moderators: helmut, XnTriq, xnview, Dreamer

User avatar
juozas
Posts: 31
Joined: Sun Sep 27, 2009 11:42 am
Location: Lithuania

0.99.1 Linux: Searching similar files traverses symlinks to other folders some times causing infinite path recursion

Post by juozas »

XnView: MP 0.99.1 - 64 bit
OS: Ubuntu Linux 20.04 LTS - 64bit

Searching for similar files in a folder that contains symlinks to other folders results in program attempting to look in the symlinked folders some times results in infinite path recursion. Screenshot:
Search similar files 2021-09-24 14_41_41.png
Effect: This results in infinite path recursion (symlink loop) when there are symlinks in the traversed path pointing to a folder that is within the same traversed path. This is undesired behavior. This usually happens when there're symlinks linking to any folder on parent dir that has symlinks to current folder and any other similar cases. Same happens when trying to use "Show files in subfolder" function, resulting in enormous memory usage and subsequent system hang after some time.
To reproduce:
1. Execute commands as shown below to create a test directory structure

Code: Select all

mkdir -p test/{Dir1,Dir2,Dir3} && cd test
2. (optional) Copy images from some folder to a subdir, e.g. run commands as show below to copy 10 random files forom a folder (replace /path/to/some/dir with a path to folder of choice)

Code: Select all

find /path/to/some/dir -maxdepth 1 -type f | shuf -n 10 | xargs -I{} cp "{}" Dir1
3. (optional) Copy files from first subdir as shown below or repeat above for other dirs (replace Dir1 with Dir2 or Dir3) for different files

Code: Select all

cp Dir1/*.* Dir2
cp Dir1/*.* Dir3
4. Create symlinks, e.g. use commands like shown below

Code: Select all

cd Dir1
ln -s ../Dir2 Dir2
ln -s ../Dir3 Dir3
cd ../Dir2
ln -s ../Dir1 Dir1
ln -s ../Dir3 Dir3
cd ../Dir3
ln -s ../Dir1 Dir1
ln -s ../Dir2 Dir2
5. Search similar files and observe infinite path recursion as shown in screenshot above.

Actual behaviour (bug): Symlinks are traversed upon similar files search and when trying to load images from subfolder, causing infinite path recursion when traversed path contains symlinks to any folder found within the search path tree some times causing enormous momory usage and subsequent system hang :bug:

Expected behaviour: No symlinks traversed anywhere in the code, infinite path recursion caused by traversed path containing symlinks to other folders found within the search path tree should not happen.
You do not have the required permissions to view the files attached to this post.
Сделано в СССР