Skip to content

symlinks interact badly with Dir; cause infinite loop/recursion #364

@smparkes

Description

@smparkes

There seems to be a symlink corner case that causes Dir expansion to infinitely loop/recur. In the test case, two multiply nested directories contain symbolic links back to their shared parent.

My test case is a directory named objc. The ls -LR contents are

~/objc ls -lR
total 0
drwxr-xr-x  3 smparkes  smparkes  102 Oct 29 13:12 examples

./examples:
total 0
drwxr-xr-x  4 smparkes  smparkes  136 Oct 29 13:13 osx

./examples/osx:
total 0
drwxr-xr-x  3 smparkes  smparkes  102 Oct 29 13:14 bare
drwxr-xr-x  3 smparkes  smparkes  102 Oct 29 13:13 demo

./examples/osx/bare:
total 8
lrwxr-xr-x  1 smparkes  smparkes  16 Sep 27 16:32 objc -> ../../../../objc

./examples/osx/demo:
total 8
lrwxr-xr-x  1 smparkes  smparkes  16 Sep 27 16:32 objc -> ../../../../objc

Should be able to create it with (bash)

mkdir -p objc/osx/{bare,demo}
ln -s ../../../../objc objc/osx/bare
ln -s ../../../../objc objc/osx/demo

Then running ruby -e 'p Dir["**/*.o"]' never returns.

Tested on 1.6.8 and 1.7.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions