groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Youri Ackx (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-2072) eachFileRecurse crashes when descending a directory with circular symbolic links
Date Fri, 02 Sep 2016 14:53:20 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-2072?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15458737#comment-15458737
] 

Youri Ackx commented on GROOVY-2072:
------------------------------------

6 years later :-) On OSX 10.11.6, the circular reference ends after a certain amount of recursion.

{code:title=circular}
youri:symlinks $ ls -l
lrwxr-xr-x   1 youri  staff     1 Sep  2 16:28 foo -> .

youri:symlinks $ ls ./foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo
ls: ./foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo/foo:
Too many levels of symbolic links
{code}

You can't even {{ls}} it. So calling this snippet:

{code:title=circular.groovy}
def f = new File('.')
f.eachFileRecurse { println it }
{code}

will not cause any crash or SO. Maybe a similar behavior exists on more recent versions of
the Linux kernel?

> eachFileRecurse crashes when descending a directory with circular symbolic links
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-2072
>                 URL: https://issues.apache.org/jira/browse/GROOVY-2072
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 1.1-beta-2
>         Environment: redhat fc5, sun java 5 or 6, ubuntu feisty, sun java 5 or 6
>            Reporter: Phil Walker
>
> The following script will quickly stack overflow on linux if the IllegalArgumentException
line is commented out.
> #!/usr/bin/env groovy
> def ff = new File("/sys/block/md0/subsystem");
> def isSymlink(ff){
>     return ff.getAbsolutePath()!=ff.getCanonicalPath() ;
> }
> ff.eachFileRecurse {
>     printf("%s\n",it);
>     if( isSymlink(it) ){
>         throw new IllegalArgumentException("circular symlinks");
>     }
> }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message