LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 07-18-2008, 10:35 AM   #1
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Rep: Reputation: 0
getaddrinfo - Segmentation fault


Hi:

I'm using the getaddrinfo call and getting a SIGSEGV. The code snippet is below.
===============
struct addrinfo hints;
struct addrinfo *result = 0;
int s;
memset(&hints,0,sizeof(struct addrinfo));
hints.ai_family = PF_UNSPEC;
if((s=getaddrinfo("server_2",NULL,&hints,&result))!=0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
}
===============

The stack trace is
===============
(gdb)
89 if((s=getaddrinfo("server_2",NULL,&hints,&result))!=0) {
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x0089abd4 in __res_vinit () from /lib/tls/i686/libc.so.6
(gdb) bt
#0 0x0089abd4 in __res_vinit () from /lib/tls/i686/libc.so.6
#1 0x0089b66e in __res_ninit () from /lib/tls/i686/libc.so.6
#2 0x0089caac in __res_maybe_init () from /lib/tls/i686/libc.so.6
#3 0x008789ea in gaih_inet () from /lib/tls/i686/libc.so.6
#4 0x008798d8 in getaddrinfo () from /lib/tls/i686/libc.so.6
#5 0x08333c1b in CicAgent::init (this=0x969e1e8) at ../src/reliability/linux/cic_agent.cxx:89
#6 0x0831e9d2 in CicDObj:rocessConfigRequest (this=0x969dac8, pRec=0x969e360)
at ../src/reliability/common/cic_dobj.cxx:129
#7 0x0831e884 in CicDObj:rocess (this=0x969dac8, pRec=0x969e360)
at ../src/reliability/common/cic_dobj.cxx:101
#8 0x0831ed87 in executeRequest (pObject=0x969dac8, pArg=0x969e360)
at ../src/reliability/common/cic_dobj.cxx:200
#9 0x081de851 in CLWorkerThread::run (this=0x969dff0)
at ../src/framework/cl_worker_thread.cxx:83
#10 0x080d0ef4 in thread_start (arg=0x969dff0) at ../src/linux/cl_basic_thread.cxx:116
#11 0x00b2b080 in start_thread () from /lib/tls/i686/libpthread.so.0
#12 0x0088e23e in clone () from /lib/tls/i686/libc.so.6
(gdb)
===============

My kernel is redhat enterprise "Linux 2.6.9-42.5610".
I am using gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)

Is there any known issue with this call with the above combination of Linux kernel and gcc library?

Thanks,

Amit.
 
Old 07-19-2008, 03:14 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Your 'hints' is invalid; use NULL instead.
 
Old 07-21-2008, 10:33 AM   #3
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Original Poster
Rep: Reputation: 0
I figured out the problem. My stack size was too small - 16K. After increasing it to 32K the problem was resolved.
 
Old 09-08-2008, 10:11 AM   #4
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 198

Rep: Reputation: 30
Hi,

I'm experiencing similar problem, can you tell me how to increase the stack size?

Best,
Chris
 
Old 09-09-2008, 10:16 PM   #5
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3

Original Poster
Rep: Reputation: 0
increase stack size in posix thread

Something like below for posix thread.
===============================
pthread_attr_t attr;

void *start(void *threadid)
{
//do something
}

int main(int argc, char *argv[])
{
pthread_t thread;
size_t stacksize;
int rc, thread_id=1;

pthread_attr_init(&attr);
pthread_attr_getstacksize (&attr, &stacksize);
stacksize = <some value>;
pthread_attr_setstacksize (&attr, stacksize);
rc = pthread_create(&thread, &attr, start, (void *)thread_id);

pthread_exit(NULL);
}

===============================
 
Old 11-26-2009, 02:34 AM   #6
deepak_akks@yahoo.com
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by gursoz View Post
Something like below for posix thread.
===============================
pthread_attr_t attr;

void *start(void *threadid)
{
//do something
}

int main(int argc, char *argv[])
{
pthread_t thread;
size_t stacksize;
int rc, thread_id=1;

pthread_attr_init(&attr);
pthread_attr_getstacksize (&attr, &stacksize);
stacksize = <some value>;
pthread_attr_setstacksize (&attr, stacksize);
rc = pthread_create(&thread, &attr, start, (void *)thread_id);

pthread_exit(NULL);
}

===============================
Hi All,
I set the stack size to 32*1024 but still I am getting Segmentation fault.
can you help me out from this?
Thanks In Advance
Deepak
 
  


Reply

Tags
linux, network, programming, software, stack


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation Fault arabindav Programming 2 03-02-2007 09:07 AM
yast segmentation fault, system freezing - nvidia driver at fault? BaltikaTroika Suse/Novell 2 12-02-2005 10:34 AM
Segmentation fault fridgider Linux - Software 1 04-09-2005 12:36 PM
segmentation fault in c++ drigz Programming 10 06-16-2004 04:06 PM
What is segmentation fault? koyi Programming 3 08-30-2003 01:03 AM


All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration