On Wed, Jun 01, 2011 at 04:27:13PM +0100, Klaus T. Aehlig wrote: > > [Please CC me, as I'm not subscribed to this list] > > Hallo, > > while dealing with PR ports/157274 [1], I found that the following > program cause a segmentation fault on 7.3-RELEASE amd64, even though > my understanding of the man page of fdopendir(3) says it should not. > > #include <fcntl.h> > #include <sys/types.h> > #include <dirent.h> > > int main(int argc, char **argv) { > DIR *dirp; > int fd; > > fd = open(".", O_RDONLY); > dirp = fdopendir(fd); > (void) readdir(dirp); > > } > > Compiling gives the warning "assignment makes pointer from integer without a > cast" > refering to the line with the fdopendir call. Indeed, adding the prototype > > extern DIR *fdopendir(int); > > right after the #include lines solves this problem. Is my understanding of > the > man page that the above #include lines should suffice incorrect? Is this > problem known---or even fixed already? > > I have reports that indicate that this problem also seems to exist on > 7.3-RELEASE-p4 amd64 > and 8.1-RELEASE i386. The above program does not segfault on my 8.2-STABLE > amd64. > > Any hints on the status of this observation are very welcome. > > Best regards, > Klaus > > > [1] http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/157274 >
This has been fixed (in include/dirent.h) with r205265 on RELENG_7, but I can't see how you'd run into the problem on 8.1. The problem was that the fdopendir prototype was missing from dirent.h, so the code was compiled using the incorrect prototype "int fdopendir()". -Mark _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"