dirent broken on x86-64/darwin

Bug #592897 reported by Cyrus Harmon
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
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]

Revision history for this message
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)
Revision history for this message
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)))

Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.