Operating System - Linux
1753809 Members
8237 Online
108805 Solutions
New Discussion юеВ

Re: gethostbyname dumps with SIGSEGV

 
Dennis Handly
Acclaimed Contributor

Re: gethostbyname dumps with SIGSEGV

I assume this is the same as the issue reported in comp.sys.hp.hpux under "gethostbyname core dumps"?

Someone mentioned that h_length in memcpy wasn't valid:
memcpy(&sin->sin_addr, hostp->h_addr_list[0], hostp->h_length);

From the man page, I have no idea whether h_length is the size of h_addr_list[0] or of all of them.

Best to use sizeof(sin->sin_addr).
David Malkson
New Member

Re: gethostbyname dumps with SIGSEGV

Yes, this is the same problem as the USENET posting.

This frament is a small part of a huge program.

WDB doesn't complain about any memory issues, but I just installed the latest SunStudio 12 and ran the Solaris version under it where memory issues are reported elsewhere.

The strange thing is WDB says it's OK and it dumps in the middle of a libc call that has a valid string as a parameter.

At this point the only conclusion I can come to is that the HP implementation of gethostbyname has some area that is reused between calls which is getting hosed.
Dennis Handly
Acclaimed Contributor

Re: gethostbyname dumps with SIGSEGV

>This fragment is a small part of a huge program.

That's why several people and I can't duplicate the abort. Have you linked with -z to catch NULL pointer dereferences?

>WDB doesn't complain about any memory issues

You're using "set heap-check on"?

>The strange thing is WDB says it's OK and it dumps in the middle of a libc call that has a valid string as a parameter.

WDB is only checking the heap usage, not everything. (It relies on the hardware to check the rest. :-)

>At this point the only conclusion I can come to is that the HP implementation of gethostbyname has some area that is reused between calls which is getting hosed.

Possibly.
Are you up to date on patches?

>the second time the function containing it is called.

Are you passing the same string the second time?
David Malkson
New Member

Re: gethostbyname dumps with SIGSEGV

I added a bunch of syslog() calls to the code, now it core dumps in syslog and the stack shows



malloc
malloc_padded
malloc
localtime_r
ctime_r
syslog

I ran a patch assessment and installed the latest patches last week

WDB 5.7 has all memory checks enabled.

CFLAGS = -Ae +w1 +ESnolit -z -g

LIBS = -lxnet -lrtc

This works flawlessly on Solaris.

I'm back to guessing it is a library compatibility issue as it has always dumped in libc.2.

I guess I could put the whole thing up on an anonymous CVS server if noone has any other hints without full sources.

Dennis Handly
Acclaimed Contributor

Re: gethostbyname dumps with SIGSEGV

>now it core dumps in syslog and the stack shows


malloc
malloc_padded
malloc

>WDB 5.7 has all memory checks enabled.

This shows the heap has been corrupted. I'm surprised gdb didn't catch it.

>CFLAGS = -Ae +w1 +ESnolit -z -g

Why are you using +ESnolit? You should use the default or +ESlit.

>I guess I could put the whole thing up on an anonymous CVS server if no one has any other hints without full sources.

I could just try the binary, if you make that available.