LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   getaddrinfo - Segmentation fault (http://www.linuxquestions.org/questions/linux-networking-3/getaddrinfo-segmentation-fault-656623/)

gursoz 07-18-2008 10:35 AM

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::processConfigRequest (this=0x969dac8, pRec=0x969e360)
at ../src/reliability/common/cic_dobj.cxx:129
#7 0x0831e884 in CicDObj::process (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.

pinniped 07-19-2008 03:14 AM

Your 'hints' is invalid; use NULL instead.

gursoz 07-21-2008 10:33 AM

I figured out the problem. My stack size was too small - 16K. After increasing it to 32K the problem was resolved.

krizzz 09-08-2008 10:11 AM

Hi,

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

Best,
Chris

gursoz 09-09-2008 10:16 PM

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

===============================

deepak_akks@yahoo.com 11-26-2009 02:34 AM

Quote:

Originally Posted by gursoz (Post 3275273)
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


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