Something is fishy with get_dir(). I had a directory with 232 directories in, where get_dir() returned an empty array. Adding a directory fixed it to return the correct result. ls had no problems, and when tracing get_dir() syscalls it looks like it gets the correct things back:
Non-working;: open(".", O_RDONLY) = 7 fpathconf(7, _PC_NAME_MAX) = 255 fcntl(7, F_SETFD, 0x00000001) = 0 fstat(7, 0xFFFFFD7FFFDF9AB0) = 0 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 8168 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 1160 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 0 close(7) = 0
Working after adding dirs: open(".", O_RDONLY) = 7 fpathconf(7, _PC_NAME_MAX) = 255 fcntl(7, F_SETFD, 0x00000001) = 0 fstat(7, 0xFFFFFD7FFFDF9AB0) = 0 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 8176 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 1224 getdents(7, 0xFFFFFD7FFEEE4000, 8192) = 0 close(7) = 0
root:~# /usr/local/bin/pike --dumpversion 7.8.116 root:~# uname -a SunOS ministore 5.11 snv_101b i86pc i386 i86pc