Date: Tue, 23 Jun 1998 06:11:53 +0800 From: Peter Wemm <peter@netplex.com.au> To: Terry Lambert <tlambert@primenet.com> Cc: joelh@gnu.org, fenner@parc.xerox.com, current@FreeBSD.ORG Subject: Re: Bogus errno twiddling by lstat... Message-ID: <199806222211.GAA04080@spinner.netplex.com.au> In-Reply-To: Your message of "Mon, 22 Jun 1998 17:36:44 GMT." <199806221736.KAA11829@usr06.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Terry Lambert wrote:
[..]
> % cat fum.c
> #include <stdio.h>
> #include "errno.h"
>
> main()
> {
> int k;
>
> for(k=0; k < 10; k++)
> printf( "default errno is %d\n", errno);
> }
> % cc -o fum fum.c -lc_r
> % ktrace fum
> % kdump
> 22622 ktrace RET ktrace 0
> 22622 ktrace CALL readlink(0x806b652,0xefbfd38c,0x3f)
> 22622 ktrace NAMI "/etc/malloc.conf"
> ****************************************
> 22622 ktrace RET readlink -1 errno 2 No such file or directory
> 22622 ktrace CALL mmap(0,0x1000,0x3,0x1002,0xffffffff,0,0,0)
> 22622 ktrace RET mmap 134328320/0x801b000
> 22622 ktrace CALL break(0x5000)
> 22622 ktrace RET break 0
> 22622 ktrace CALL break(0x6000)
> 22622 ktrace RET break 0
> ...
> 22622 ktrace NAMI "/usr/X11R6/bin/fum"
> 22622 ktrace RET execve -1 errno 2 No such file or directory
> 22622 ktrace CALL execve(0xefbfd438,0xefbfd8f8,0xefbfd900)
> 22622 ktrace NAMI "./fum"
> 22622 fum RET execve 0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 22622 fum CALL open(0x109c,0,0)
> 22622 fum NAMI "/usr/libexec/ld.so"
> 22622 fum RET open 3
> 22622 fum CALL read(0x3,0xefbfd8a0,0x20)
> 22622 fum GIO fd 3 read 32 bytes
> "\M-L\0\M^F\M-@\0\M-`\0\0\0 \0\0$\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0
"
> 22622 fum RET read 32/0x20
> ...
> 22622 fum RET sigprocmask 0
> 22622 fum CALL sigprocmask(0x3,0)
> 22622 fum RET sigprocmask -65793/0xfffefeff
> 22622 fum CALL readlink(0x8072782,0xefbfd730,0x3f)
> 22622 fum NAMI "/etc/malloc.conf"
> ****************************************
> 22622 fum RET readlink -1 errno 2 No such file or directory
> 22622 fum CALL mmap(0,0x1000,0x3,0x1002,0xffffffff,0,0,0)
> 22622 fum RET mmap 134324224/0x801a000
>
>
> > malloc() has been adjusted to preserve errno across the readlink(), so I
> > suggest you leave it at that rather than digging youself an even deeper
> > hole. :-)
>
> Thank you for making the change; however, you can clearly see that
> the /etc/malloc.conf file is beaing readlink'ed twice.
Of course it does when you exec a new executable!!
>
> Terry Lambert
> terry@lambert.org
> ---
> Any opinions in this posting are my own and not those of my present
> or previous employers.
>
Cheers,
-Peter
--
Peter Wemm <peter@netplex.com.au> Netplex Consulting
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806222211.GAA04080>
