Bug 32741

Summary: Getting segmentation fault in connect system call
Product: Base System Reporter: Lokendra Kr. Verma <lokendra>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
lokendra.vcf
none
lokendra.vcf none

Description Lokendra Kr. Verma 2001-12-12 09:00:01 UTC
Sir, i m using freeBSD version 4.3.
I m making .so library of my application. This application establish
socket connection with remote machines. My problem is that when i link
this .so library with my main program and call the function of .so
library , i get segmentation fault on connect and inet_pton system
calls.
Instead of making .so library if i make the exe of my application and
then i do not get any segmentation fault.

Help me sir or suggest me somebody who can help me out.
I say thanx in advance.
Lokendra

Fix: 

i do not know.
How-To-Repeat: To repeat the problems, i have written simple client server programs 
for the socket communication. Instead of making exe of both the programs 
i have build (client.so and server.so) .so libraries separatly. 
Now for both the library i have written main function which calls 
the initial function of .so library.
now when i run server program i get segmentation fault in accept 
system call and when i run client program i get segmentation fault 
in connect system call.
I can send u the files which will make u understand the problem better.
Comment 1 Sheldon Hearn 2001-12-12 09:11:00 UTC
On Wed, 12 Dec 2001 00:59:03 PST, "Lokendra Kr. Verma" wrote:

> >Description:
> Sir, i m using freeBSD version 4.3.
> I m making .so library of my application. This application establish
> socket connection with remote machines. My problem is that when i link
> this .so library with my main program and call the function of .so
> library , i get segmentation fault on connect and inet_pton system
> calls.

Since you're skilled enough to be building libraries and stuff, can't
you build your module with debugging symbols and use the debugger to
analyze your core dump?

Ciao,
Sheldon.
Comment 2 Lokendra Kr. Verma 2001-12-12 09:24:51 UTC
Hello sir,
Thanx for quick response.
I have already done it using gdb. Now i m sending u the detail which gdb is
showing.
////////////////////////////////////////////////////////////////////////
Running my client program without gdb following is the output.
*****************************
/run 5555
before calling connect
Segmentation fault (core dumped)
/////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
Running my client program with gdb following is the output.
*****************************
%gdb run
GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are

welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-freebsd"...
(gdb) r 5555
Starting program: /home/lokendra/connecttesting/run 5555

 Before calling connect

Program received signal SIGSEGV, Segmentation fault.
0x280c7f46 in xdr_u_int () from /usr/lib/libc.so.4
(gdb) where
#0  0x280c7f46 in xdr_u_int () from /usr/lib/libc.so.4
#1  0x280c86aa in xdr_bytes () from /usr/lib/libc.so.4
#2  0x280c877c in xdr_netobj () from /usr/lib/libc.so.4
#3  0x280ddfba in .cerror () from /usr/lib/libc.so.4
#4  0x2806589e in start () from /home/lokendra/connecttesting/./client.so
#5  0x8048589 in main (argc=2, argv=0xbfbffb90) at main.c:10
#6  0x80484b5 in _start ()
///////////////////////////////////////////////////////////////////////////////////////////////////////

if u need files, i can send those tooooo.
Thanx for yor reply and waiting yor reply.
Regards
Lokendra.


Sheldon Hearn wrote:

> On Wed, 12 Dec 2001 00:59:03 PST, "Lokendra Kr. Verma" wrote:
>
> > >Description:
> > Sir, i m using freeBSD version 4.3.
> > I m making .so library of my application. This application establish
> > socket connection with remote machines. My problem is that when i link
> > this .so library with my main program and call the function of .so
> > library , i get segmentation fault on connect and inet_pton system
> > calls.
>
> Since you're skilled enough to be building libraries and stuff, can't
> you build your module with debugging symbols and use the debugger to
> analyze your core dump?
>
> Ciao,
> Sheldon.
Comment 3 Sheldon Hearn 2001-12-12 09:34:39 UTC
On Wed, 12 Dec 2001 14:54:51 +0530, "Lokendra Kr. Verma" wrote:

> I have already done it using gdb. Now i m sending u the detail which gdb is
> showing.

It doesn't look like your library was built with debugging symbols?

Ciao,
Sheldon.
Comment 4 alex.neyman 2001-12-18 07:03:38 UTC
Adding to Audit-Trail.

This PR can be closed.

----------  Forwarded Message  ----------
Subject: Re: kern/32741: Getting segmentation fault in connect system call
Date: Tue, 18 Dec 2001 12:29:59 +0530
From: "Lokendra Kr. Verma" <lokendra@npi.stpn.soft.net>
To: "Alexey V. Neyman" <alex.neyman@auriga.ru>



Hello sir,
Thanx for reply.
I got solved this problem last weak. U r right actually.
I was building my .so file using libc_r library which is thread safe. But
the exe on which this .so shall be loaded was not thread safe. I was
linking the exe with libc which is not thread safe on freeBSD.
Now everything is ok. Once again i say thanx.....
PLease keep in touch.
Lokendra

"Alexey V. Neyman" wrote:

> Hello there,
>
> seems that you have an isolated test case; may I have a look at it?
> (the backtrace shown in PR does not look like that you're crashing in
> connect(2), but rather you've got shared object linked incorrectly).
>
> What options do you pass to compiler/linker to build client.so?
>
> Regards,
> Alexey.
>
> --
> <------------------------->
>  ) May the Sun and Water (   Regards, Alexey V. Neyman
>  ) always fall upon you! (   mailto:alex.neyman@auriga.ru
> <------------------------->


-------------------------------------------------------

-- 
<------------------------->
 ) May the Sun and Water (   Regards, Alexey V. Neyman
 ) always fall upon you! (   mailto:alex.neyman@auriga.ru
<------------------------->
Comment 5 Bruce A. Mah freebsd_committer freebsd_triage 2001-12-18 17:11:45 UTC
State Changed
From-To: open->closed

Problem solved, according to follow-up from  
"Alexey V. Neyman" <alex.neyman@auriga.ru>.