Steel Bank Common Lisp

dirent broken on x86-64/darwin

Reported by Cyrus Harmon on 2010-06-12
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
High
Cyrus Harmon

Bug Description

something about dirent is hosed on x86-64/darwin on SBCL 1.0.39.10 (and earlier):

* (let ((dir (sb-posix:opendir "/"))
        (sb-alien::*default-c-string-external-format* :latin-1))
    (unwind-protect
       (block dir-loop
         (loop for dirent = (sb-posix:readdir dir)
               until (sb-alien:null-alien dirent)
               when (not (stringp (sb-posix:dirent-name dirent)))
                 do (return-from dir-loop nil)
               finally (return t
      (sb-posix:closedir dir)))

T
*
(let ((dir (sb-posix:opendir "/")))
  (unwind-protect
       (block dir-loop
         (loop for dirent = (sb-posix:readdir dir)
            until (sb-alien:null-alien dirent)
            when (not (stringp (print (sb-posix:dirent-name dirent))))
            do (return-from dir-loop nil)
            finally (return t)))
    (sb-posix:closedir dir)))

"."
"DS_Store"
":"
""
""
"ee"
"00"
"e"
""
"00"
"ores"
""
"eveloper"
"`"
"ome"
""
""
debugger invoked on a SB-INT:C-STRING-DECODING-ERROR in thread #<THREAD
                                                                 "initial thread" RUNNING
                                                                 {100371F841}>:
  c-string decoding error (:external-format :UTF-8):
    the octet sequence 4 cannot be decoded.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-INT:C-STRING-DECODING-ERROR :UTF-8 4)
0]

Luís Oliveira (luismbo) wrote :

Some cross-checking with Osicat (which works fine) seems to indicate that the DIRENT struct definition is correct and the problem lies with readdir(). Calling readdir$INODE64() instead seems to fix the problem.

Changed in sbcl:
importance: Undecided → High
assignee: nobody → Cyrus Harmon (ch-launchpad)
Cyrus Harmon (ch-launchpad) wrote :

The first test up above got messed up. It should be:

(let ((dir (sb-posix:opendir "/"))
      (sb-alien::*default-c-string-external-format* :latin-1))
  (unwind-protect
       (block dir-loop
         (loop for dirent = (sb-posix:readdir dir)
            until (sb-alien:null-alien dirent)
            when (not (stringp (sb-posix:dirent-name dirent)))
            do (return-from dir-loop nil)
            finally (return t)))
    (sb-posix:closedir dir)))

Cyrus Harmon (ch-launchpad) wrote :

it's not dirent that's broken, so much as readdir. fix committed in 1.0.39.11.

Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers