[haiku-bugs] [Haiku] #5008: readdir_r crashes

  • From: "MrSunshine" <trac@xxxxxxxxxxxx>
  • Date: Fri, 20 Nov 2009 11:57:27 -0000

#5008: readdir_r crashes
-------------------------------+--------------------------------------------
 Reporter:  MrSunshine         |       Owner:  axeld         
     Type:  bug                |      Status:  new           
 Priority:  high               |   Milestone:  R1            
Component:  System/libroot.so  |     Version:  R1/Development
 Keywords:                     |   Blockedby:                
 Platform:  x86                |    Blocking:                
-------------------------------+--------------------------------------------
 using this test on my computer readdir_r crashes for me and outputs
 jibberish. Might be me doing something wrong tho but cant figure out what
 =)

 {{{
 #include <sys/types.h>
 #include <dirent.h>
 #include <errno.h>
 #include <stdio.h>

 main() {
   DIR *dir = opendir("/boot/home");
   struct dirent *d;
   struct dirent d_mem;
   int ret;
   while ((ret = readdir_r(dir, &d_mem, &d)) == 0) {
     printf("%s %d\n", d->d_name, ret);
   }
   closedir(dir);
 }
 }}}


 output:[[BR]]
 ~> ./a.out[[BR]]
 . 0[[BR]]
 ..H@r 0[[BR]]
 .bHhist 0[[BR]]
 Kill Thread[[BR]]
 ~> [[BR]]

 actual content:[[BR]]
 ~> ls -la[[BR]]
 total 86[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 20 12:53 .[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 17 00:49 ..[[BR]]
 -rw------- 1 user root  1936 Nov 20 11:23 .bash_history[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 17 10:25 .config[[BR]]
 -rw------- 1 user root    77 Nov 20 11:56 .cvspass[[BR]]
 -rw------- 1 user root 11884 Nov 20 12:53 .viminfo[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 18 17:38 Desktop[[BR]]
 -rwxr-xr-x 1 user root  5443 Nov 20 11:49 a.out[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 17 00:51 config[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 17 00:54 mail[[BR]]
 drwxr-xr-x 1 user root  2048 Nov 18 08:38 queries[[BR]]
 -rwxr-xr-x 1 user root  5632 Nov 17 20:54 test[[BR]]
 -rw-r--r-- 1 user root  1187 Nov 20 11:19 test.c[[BR]]
 -rw-r--r-- 1 user root   310 Nov 20 11:49 test2.c[[BR]]

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/5008>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: