#620 self-recursive dead-link

lisp error
open
Bruno Haible
clisp (525)
5
2011-12-05
2011-12-05
Gabor Balazs
No

CLISP cannot probe/list a dead link which points to itself.
The probe-file, probe-pathname, directory functions always end up in an infinite loop which results to a UNIX error.

Setup:

mkdir /tmp/TEST
cd /tmp/TEST
ln -s dead dead
ls -l dead
lrwxrwxrwx 1 bege users 4 Dec 4 20:45 dead -> dead

Problem:

CLISP> (probe-pathname "dead")
*** - UNIX error 40 (ELOOP): Too many levels of symbolic links

CLISP> (probe-file "dead")
*** - UNIX error 40 (ELOOP): Too many levels of symbolic links

CLISP> (directory "./*" :if-does-not-exist :keep)
*** - UNIX error 40 (ELOOP): Too many levels of symbolic links

CLISP> (directory "./*" :if-does-not-exist :keep :circle t)
*** - UNIX error 40 (ELOOP): Too many levels of symbolic links

Desired behavior:

CLISP> (probe-file "dead") => NIL
CLISP> (probe-pathname "dead") => NIL

CLISP> (directory "./*" :if-does-not-exist :keep) => (#P"/tmp/TEST/dead")
or
CLISP> (directory "./*" :if-does-not-exist :keep :circle t) => (#P"/tmp/TEST/dead")

Version:
GNU CLISP 2.49 (2010-07-07) (built 3529014440) (memory 3529014964)
Software: GNU C 4.5.3
gcc -O2 -march=core2 -fomit-frame-pointer -pipe -Wa,--noexecstack -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wmissing-declarations -Wno-sign-compare -Wno-format-nonliteral -O -falign-functions=4 -pthread -DENABLE_UNICODE -DMULTITHREAD -DPOSIX_THREADS -DDYNAMIC_FFI -I. -Wl,-O1 -Wl,--as-needed /usr/lib64/libreadline.so -lncurses -ldl /usr/lib64/libavcall.a /usr/lib64/libcallback.a -L/usr/lib64 -lsigsegv -L/usr/lib64 -lc libgnu_cl.a
SAFETY=0 TYPECODES WIDE_HARD GENERATIONAL_GC SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.8
libreadline 6.2
Features:
(READLINE REGEXP SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP
LISP=CL INTERPRETER MT SOCKETS GENERIC-STREAMS LOGICAL-PATHNAMES SCREEN FFI
GETTEXT UNICODE BASE-CHAR=CHARACTER WORD-SIZE=64 PC386 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib64/clisp-2.49/
User language: ENGLISH
Machine: X86_64 (X86_64) localhost [127.0.0.1]

`bg`

Discussion

  • Bruno Haible
    Bruno Haible
    2011-12-05

    When there is a cycle in the resolution of symbolic links, it is not one of the common situations:
    - A link without target can be fixed by adding a file at the target location.
    - A link with target can be open()ed.
    The UNIX designers found it useful to assign the error code ELOOP to a situation other than these two.

    I don't see a compelling reason why CLISP should deviate from the usual UNIX treatment of this situation.

    What you propose is equivalent to sweeping an error situation under the rug.
    This is sometimes justified, with a good, compelling, convincing, universally accepted rationale.
    But you have not provided such a rationale in this case.

     
  • Bruno Haible
    Bruno Haible
    2011-12-05

    • status: open --> closed-rejected
     
  • Gabor Balazs
    Gabor Balazs
    2011-12-05

    Some rationale:

    ABCL, CCL, ECL, SBCL, SCL can handle this situation without error.

    The ls, ls -l UNIX commands can handle this situation without error.

    But most importantly, a self-recursive dead link cannot be listed in CLISP. The directory command will always result an ELOOP error without the :discard or :ignore options. So the directory function either ignores these dead links completely or produces an error. This means that such self-recursive dead links cannot be handled in CLISP at all and directories having them cannot be deleted as well.

    It would be desirable to have an option for the directory function with which it is able to list these self-recursive dead links too.

     
  • Gabor Balazs
    Gabor Balazs
    2011-12-05

    Furthermore, the error situation is not swept under the rug. It could be handled exactly the same way as usual dead link. When the dead link is not self-recursive, one can list it by the (directory "./*" :full t :if-does-not-exist :keep) call. When the link is dead, the corresponding entry will be a single pathname instead of a (file-pathname file-truename file-write-date-as-decoded-time file-length) list. This is how dead links can be found in CLISP. Then based on the pathname, it is possible to check whether a dead link is self-recursive or not. So I don't see any information being lost by my proposal.

     
  • Sam Steingold
    Sam Steingold
    2011-12-05

    Throwing a system error is, effectively, an admission of defeat.
    CLISP can do better.

     
  • Sam Steingold
    Sam Steingold
    2011-12-05

    • status: closed-rejected --> open