[729] in linux-net channel archive
Re: malloc() woes?
daemon@ATHENA.MIT.EDU (Andrew Walker)
Wed Jul 19 14:44:10 1995
From: andy@keo.kvaerner.no (Andrew Walker)
To: scottr@msn.fullfeed.com
Date: Wed, 19 Jul 1995 08:49:22 +0200 (MET DST)
Cc: linux-gcc@vger.rutgers.edu, linux-net@vger.rutgers.edu
In-Reply-To: <199507190004.TAA00851@belle.msn.fullfeed.com> from "System Mangler" at Jul 18, 95 07:04:49 pm
System Mangler wrote:
>
> Hello,
> I'm probably just really stupid, but the following code segment
> causes a seg fault under any circumstance. The from field in the
> client is a "struct sockaddr_in *" This code used to work, I'm not
> sure what i changed in the program, but it had nothing to do with
> this code anyway. All of the arguments to gethostbyaddr are correct (
> as far as i can tell by stepping through the code with gdb), but
> gdb stops the program in the middle of gethostbyaddr with a SIGSEGV
> in malloc().
> I have another portion of this code that also seg faults in the
> middle of a malloc() call. Under what conditions should malloc()
> do this (with the exception of a bad parameter)?
>
> const char *net_client_address(struct register_info *client) {
> struct hostent *hp;
> struct in_addr temp;
>
> temp=client->from->sin_addr;
>
> hp=gethostbyaddr((char *)&temp, sizeof(struct in_addr), AF_INET);
> if (hp==NULL) {
> s_errno=h_errno;
> herror("gethostbyaddr");
> return NULL;
> }
> return hp->h_name;
> }
>
> the other instance that i get seg faults in malloc() is just a simple
>
> temp=(struct user_info *)malloc (sizeof(struct user_info));
>
> which works the first two times its called, and then never after.
>
> Thanks. Please dont send mail to <root@belle.msn.fullfeed.com>, it wont work.
> Send any mail to <scottr@msn.fullfeed.com>
>
Hi,
I too have a problem with code using malloc(), in libc 5.2.3. I assumed the
problem was in the nfs server code (nfs-server-2.2beta2) until I read this posting.
Now I'm not so sure.
I get segmentation faults in malloc when re-initializing the authority stuff
from /etc/exports, but before that I also get some wierd effects mounting file
systems from my Linux box.
I have a very simple /etc/exports, which contains just:
/usr/local (rw)
which should export /usr/local as read-write to any clients that want it. When
I mount it from a Sun 3/80 (SunOS 4.1.1) I see the directory structure, but the
permisions are real screwy. I can create, but not modify files in a tmp directory
(permisions drwxrwxrwt). Users can't even create files in directories that they own.
If /etc/exports is changed to:
/usr/local fulcrum(rw)
where fulcrum is the name of the client then the permissions are ok.
If I send a SIGHUP to rpc.nfsd or rpc.mountd to re-read /etc/exports they both
die with SIGSEGV in malloc, called from auth_init() doing a re-initialize.
I'll try to debug things a bit tonight, if I get time.
-Andy
--
Andy Walker Kvaerner Engineering a.s.
Andrew.Walker@keo.kvaerner.no P.O. Box 222, N-1324 Lysaker, Norway
......if the answer isn't violence, neither is it silence......