LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , , , , ,

Reply
 
Thread Tools
Old 07-18-2008, 10:35 AM   #1
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3
Thanked: 0
getaddrinfo - Segmentation fault


[Log in to get rid of this advertisement]
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.
gursoz is offline  
Tag This Post , , ,
Reply With Quote
Old 07-19-2008, 03:14 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732
Thanked: 6
Your 'hints' is invalid; use NULL instead.
pinniped is offline     Reply With Quote
Old 07-21-2008, 10:33 AM   #3
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3
Thanked: 0

Original Poster
I figured out the problem. My stack size was too small - 16K. After increasing it to 32K the problem was resolved.
gursoz is offline     Reply With Quote
Old 09-08-2008, 10:11 AM   #4
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 174
Thanked: 0
Hi,

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

Best,
Chris
krizzz is offline     Reply With Quote
Old 09-09-2008, 10:16 PM   #5
gursoz
LQ Newbie
 
Registered: Feb 2007
Posts: 3
Thanked: 0

Original Poster
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);
}

===============================
gursoz is offline  
Tag This Post , , ,
Reply With Quote

Reply

Bookmarks


Thread Tools

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 10:54 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration