<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: gethostbyname dumps with SIGSEGV in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111567#M92765</link>
    <description>Can I assume that you are first testing to see if a NULL pointer is returned before referencing any fields within the struct? If not, that would certainly trigger a SIGSEGV.</description>
    <pubDate>Tue, 04 Dec 2007 20:13:10 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-12-04T20:13:10Z</dc:date>
    <item>
      <title>gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111565#M92763</link>
      <description>I'm porting an application from Linux to Solaris, and now HP-UX.&lt;BR /&gt;&lt;BR /&gt;The HP-UX port gets SIGSEGV in gethostbyname the second time the function containing it is called.&lt;BR /&gt;&lt;BR /&gt;I'm compiling -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE, linking dynamically, and the program is not threaded.&lt;BR /&gt;&lt;BR /&gt;Any clues where to look?</description>
      <pubDate>Tue, 04 Dec 2007 19:53:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111565#M92763</guid>
      <dc:creator>David Malkson</dc:creator>
      <dc:date>2007-12-04T19:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111566#M92764</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Verify your arrays are sized correctly and that your pointers are valid.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 04 Dec 2007 20:02:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111566#M92764</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-12-04T20:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111567#M92765</link>
      <description>Can I assume that you are first testing to see if a NULL pointer is returned before referencing any fields within the struct? If not, that would certainly trigger a SIGSEGV.</description>
      <pubDate>Tue, 04 Dec 2007 20:13:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111567#M92765</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-12-04T20:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111568#M92766</link>
      <description>If it's not too big post the code here so we can take the guesswork out of it.</description>
      <pubDate>Tue, 04 Dec 2007 21:03:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111568#M92766</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-12-04T21:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111569#M92767</link>
      <description>&lt;!--!*#--&gt;OK, here's the source:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;static&lt;BR /&gt;int resolv_hostname( const char *hname,struct sockaddr_in *sin ){&lt;BR /&gt;  struct hostent *hostp = NULL;&lt;BR /&gt;  unsigned long addr;&lt;BR /&gt;&lt;BR /&gt;  addr = inet_addr( hname );&lt;BR /&gt;  if (addr != (in_addr_t)-1)&lt;BR /&gt;    memcpy( &amp;amp;sin-&amp;gt;sin_addr, &amp;amp;addr, sizeof( addr ));&lt;BR /&gt;  else {&lt;BR /&gt;    hostp = gethostbyname( hname );&lt;BR /&gt;    if( hostp == NULL )&lt;BR /&gt;      return -1;&lt;BR /&gt;    else&lt;BR /&gt;      memcpy( &amp;amp;sin-&amp;gt;sin_addr, hostp-&amp;gt;h_addr_list[0], hostp-&amp;gt;h_length );&lt;BR /&gt;  }&lt;BR /&gt;  return 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;It SIGSEGV's in the gethostbyname call.&lt;BR /&gt;&lt;BR /&gt;The WDB stack says:&lt;BR /&gt;&lt;BR /&gt;strlen+0xc&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt; + 0x64&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt; + 0x108&lt;BR /&gt;nss_search+0x114&lt;BR /&gt;__getghostbyname+0x140&lt;BR /&gt;gethostbyname+0x94&lt;BR /&gt;&lt;BR /&gt;all from /usr/lib/libc.2&lt;BR /&gt;&lt;BR /&gt;The hname variable is valid and contains a valid hostname string.&lt;BR /&gt;&lt;BR /&gt;Copying the hname value to a big temporary buffer string makes no difference.&lt;BR /&gt;&lt;/UNKNOWN_PROCEDURE&gt;&lt;/UNKNOWN_PROCEDURE&gt;</description>
      <pubDate>Tue, 04 Dec 2007 21:38:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111569#M92767</guid>
      <dc:creator>David Malkson</dc:creator>
      <dc:date>2007-12-04T21:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111570#M92768</link>
      <description>Some things that you may want to look at. The argument types do not agree with the prototypes of most functions you are using:&lt;BR /&gt;&lt;BR /&gt;change...  unsigned long addr;&lt;BR /&gt;to...     struct in_addr addr;&lt;BR /&gt;&lt;BR /&gt;if ((addr = inet_addr(hname)) == -1)&lt;BR /&gt;...</description>
      <pubDate>Tue, 04 Dec 2007 22:17:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111570#M92768</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-12-04T22:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111571#M92769</link>
      <description>According to the man page, that should be in_addr_t, not a struct.&lt;BR /&gt;&lt;BR /&gt;I changed it to in_addr_t and it made no difference.&lt;BR /&gt;&lt;BR /&gt;FWIW, the Linux and Solaris ports run just fine and according to all the tools the other OS's have no memory issues.&lt;BR /&gt;&lt;BR /&gt;That leads me to think it is some some include, define, compile switch, or library issue with the HP-UX port.</description>
      <pubDate>Tue, 04 Dec 2007 23:18:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111571#M92769</guid>
      <dc:creator>David Malkson</dc:creator>
      <dc:date>2007-12-04T23:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111572#M92770</link>
      <description>Since your program is pretty short why don't you post the entire code along with the list of include'd header files and the command you are using for compiling.&lt;BR /&gt;&lt;BR /&gt;~thanks</description>
      <pubDate>Wed, 05 Dec 2007 03:53:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111572#M92770</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-12-05T03:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111573#M92771</link>
      <description>Ooops hit the submit button prematurely. Trying to clear confusion caused by... &lt;BR /&gt;&lt;BR /&gt;&amp;gt; if ((addr = inet_addr(hname)) == -1)&lt;BR /&gt;&lt;BR /&gt;when I meant...&lt;BR /&gt;&lt;BR /&gt;if ((addr.s_addr = inet_addr(hname)) == -1)&lt;BR /&gt;&lt;BR /&gt;where s_addr is a member of the in_addr structure and is of type in_addr_t.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Dec 2007 04:12:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111573#M92771</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-12-05T04:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111574#M92772</link>
      <description>&amp;gt;According to the man page, that should be in_addr_t, not a struct.&lt;BR /&gt;&lt;BR /&gt;Right.&lt;BR /&gt;I had to use in_addr_t so it would work in 64 bit mode.</description>
      <pubDate>Wed, 05 Dec 2007 04:23:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111574#M92772</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-05T04:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111575#M92773</link>
      <description>I assume this is the same as the issue reported in comp.sys.hp.hpux under "gethostbyname core dumps"?&lt;BR /&gt;&lt;BR /&gt;Someone mentioned that h_length in memcpy wasn't valid:&lt;BR /&gt;memcpy(&amp;amp;sin-&amp;gt;sin_addr, hostp-&amp;gt;h_addr_list[0], hostp-&amp;gt;h_length);&lt;BR /&gt;&lt;BR /&gt;From the man page, I have no idea whether h_length is the size of h_addr_list[0] or of all of them.&lt;BR /&gt;&lt;BR /&gt;Best to use sizeof(sin-&amp;gt;sin_addr).</description>
      <pubDate>Thu, 06 Dec 2007 09:16:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111575#M92773</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-06T09:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111576#M92774</link>
      <description>Yes, this is the same problem as the USENET posting.&lt;BR /&gt;&lt;BR /&gt;This frament is a small part of a huge program.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Sat, 08 Dec 2007 17:49:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111576#M92774</guid>
      <dc:creator>David Malkson</dc:creator>
      <dc:date>2007-12-08T17:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111577#M92775</link>
      <description>&amp;gt;This fragment is a small part of a huge program.&lt;BR /&gt;&lt;BR /&gt;That's why several people and I can't duplicate the abort.  Have you linked with -z to catch NULL pointer dereferences?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;WDB doesn't complain about any memory issues&lt;BR /&gt;&lt;BR /&gt;You're using "set heap-check on"?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;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.&lt;BR /&gt;&lt;BR /&gt;WDB is only checking the heap usage, not everything.  (It relies on the hardware to check the rest.  :-)&lt;BR /&gt;&lt;BR /&gt;&amp;gt;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.&lt;BR /&gt;&lt;BR /&gt;Possibly.&lt;BR /&gt;Are you up to date on patches?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;the second time the function containing it is called.&lt;BR /&gt;&lt;BR /&gt;Are you passing the same string the second time?</description>
      <pubDate>Sat, 08 Dec 2007 22:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111577#M92775</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-08T22:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111578#M92776</link>
      <description>I added a bunch of syslog() calls to the code, now it core dumps in syslog and the stack shows &lt;BR /&gt;&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt;&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt;&lt;BR /&gt;malloc&lt;BR /&gt;malloc_padded&lt;BR /&gt;malloc&lt;BR /&gt;localtime_r&lt;BR /&gt;ctime_r&lt;BR /&gt;syslog&lt;BR /&gt;&lt;BR /&gt;I ran a patch assessment and installed the latest patches last week&lt;BR /&gt;&lt;BR /&gt;WDB 5.7 has all memory checks enabled.&lt;BR /&gt;&lt;BR /&gt;CFLAGS = -Ae +w1 +ESnolit -z -g &lt;BR /&gt;&lt;BR /&gt;LIBS = -lxnet -lrtc&lt;BR /&gt;&lt;BR /&gt;This works flawlessly on Solaris.&lt;BR /&gt;&lt;BR /&gt;I'm back to guessing it is a library compatibility issue as it has always dumped in libc.2.&lt;BR /&gt;&lt;BR /&gt;I guess I could put the whole thing up on an anonymous CVS server if noone has any other hints without full sources.&lt;BR /&gt;&lt;BR /&gt;&lt;/UNKNOWN_PROCEDURE&gt;&lt;/UNKNOWN_PROCEDURE&gt;</description>
      <pubDate>Mon, 10 Dec 2007 20:51:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111578#M92776</guid>
      <dc:creator>David Malkson</dc:creator>
      <dc:date>2007-12-10T20:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: gethostbyname dumps with SIGSEGV</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111579#M92777</link>
      <description>&amp;gt;now it core dumps in syslog and the stack shows&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt;&lt;BR /&gt;&lt;UNKNOWN_PROCEDURE&gt;&lt;BR /&gt;malloc&lt;BR /&gt;malloc_padded&lt;BR /&gt;malloc&lt;BR /&gt;&lt;BR /&gt;&amp;gt;WDB 5.7 has all memory checks enabled.&lt;BR /&gt;&lt;BR /&gt;This shows the heap has been corrupted.  I'm surprised gdb didn't catch it.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;CFLAGS = -Ae +w1 +ESnolit -z -g&lt;BR /&gt;&lt;BR /&gt;Why are you using +ESnolit?  You should use the default or +ESlit.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I guess I could put the whole thing up on an anonymous CVS server if no one has any other hints without full sources.&lt;BR /&gt;&lt;BR /&gt;I could just try the binary, if you make that available.&lt;/UNKNOWN_PROCEDURE&gt;&lt;/UNKNOWN_PROCEDURE&gt;</description>
      <pubDate>Mon, 10 Dec 2007 23:07:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gethostbyname-dumps-with-sigsegv/m-p/4111579#M92777</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-10T23:07:06Z</dc:date>
    </item>
  </channel>
</rss>

