<?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: 11.23 IA doesnt dump core during copy into NULL pointer in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173463#M321483</link>
    <description>&amp;gt;&amp;gt; i needed it to dump core on IA simular to the PA-RISC systems so that i can capture the same is sighandler and terminate the process...&lt;BR /&gt;&lt;BR /&gt;I see the words, but I'm having a hard time making sense out of them.&lt;BR /&gt;&lt;BR /&gt;A program which provides a NULL pointer as target for strcpy is broken. What is the point in setting up a mechanism to capture the failure? Fix it! The program _could_ test the result for strcpy.&lt;BR /&gt;&lt;BR /&gt;How about writting your own strcpy? It is not rocket science to get the functionality in place either as a macro, or as a function. To get it optimal is more work.&lt;BR /&gt;&lt;BR /&gt;Hwo about writing a jacket routine with the same name. On first activation have is use dlopen/dlsym to find an address for the read strcpy. Next try to write a byte into the destination pointer. If that works, call the real strcpy through its dyna,icly obtained address (strcpy_pointer). If it fails, then you'll have your signal.&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
    <pubDate>Thu, 03 Apr 2008 17:42:36 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2008-04-03T17:42:36Z</dc:date>
    <item>
      <title>11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173458#M321478</link>
      <description>the below prog dumps SIGBUS core on v11.11 PA-RISC(32-bit) machine while works fine on V11.23 Itanium(64-bit) with same compiler options.&lt;BR /&gt;CC Compiler details:&lt;BR /&gt;PA-RISC:&lt;BR /&gt;        $Revision: 92453-07 linker linker crt0.o B.11.16.01 030316 $&lt;BR /&gt;        LINT B.11.11.29484.GP CXREF B.11.11.29484.GP&lt;BR /&gt;        HP92453-01 B.11.11.29484.GP HP C &lt;BR /&gt;ITANIUM:&lt;BR /&gt;HP aC++/ANSI C B3910B A.05.50 [May 15 2003]&lt;BR /&gt;Any clues on what causes the difference&lt;BR /&gt;---&lt;BR /&gt;char *pszTemp = NULL;&lt;BR /&gt;strcpy(pszTemp, "copy into NULL pinter");&lt;BR /&gt;---&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Apr 2008 14:43:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173458#M321478</guid>
      <dc:creator>siba</dc:creator>
      <dc:date>2008-04-03T14:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173459#M321479</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;As far as i know, Application compiled for 64bit will not work on 32bit system. You may need to recompile that&lt;BR /&gt;&lt;BR /&gt;Application compiled for 32 bit may work on 64bit OS, but again in order to get optimization, need to recompile for 64bit.&lt;BR /&gt;&lt;BR /&gt;Thank You, Have a Good Day!!!&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Ramesh S</description>
      <pubDate>Thu, 03 Apr 2008 14:58:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173459#M321479</guid>
      <dc:creator>Ramesh S</dc:creator>
      <dc:date>2008-04-03T14:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173460#M321480</link>
      <description>Looks to me like strcpy() in the current IPF implementation is just not stupid enough to write to NULL. Consider:&lt;BR /&gt;&lt;BR /&gt;# cat stupid.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;#include &lt;STRINGS.H&gt;&lt;BR /&gt;&lt;BR /&gt;int&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;        char *pszTemp = NULL;&lt;BR /&gt;&lt;BR /&gt;        printf("pszTemp: 0x%lp\n", pszTemp);&lt;BR /&gt;&lt;BR /&gt;        strcpy(pszTemp, "copy into NULL pointer");&lt;BR /&gt;&lt;BR /&gt;        printf("Copied\n");&lt;BR /&gt;&lt;BR /&gt;        pszTemp[0] = 'c';&lt;BR /&gt;        pszTemp[1] = '\0';&lt;BR /&gt;&lt;BR /&gt;        printf("Out\n");&lt;BR /&gt;        exit(EXIT_SUCCESS);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# cc +DD64 -o stupid stupid.c   &lt;BR /&gt;# ./stupid&lt;BR /&gt;pszTemp: 0x0000000000000000&lt;BR /&gt;Copied&lt;BR /&gt;Memory fault(coredump)&lt;BR /&gt;&lt;BR /&gt;If/when I remove the direct write to NULL, the program runs to completion. &lt;BR /&gt;&lt;BR /&gt;So it isn't a matter of the binary or platform layout -- it is the copy itself. memcpy() does not have the same behavior:&lt;BR /&gt;# cat stupid.c&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STRING.H&gt;&lt;BR /&gt;#include &lt;STRINGS.H&gt;&lt;BR /&gt;&lt;BR /&gt;char *copy_const_string = "copy into NULL pointer";&lt;BR /&gt;&lt;BR /&gt;int&lt;BR /&gt;main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;        char *pszTemp = NULL;&lt;BR /&gt;&lt;BR /&gt;        printf("pszTemp: 0x%lp\n", pszTemp);&lt;BR /&gt;&lt;BR /&gt;        strcpy(pszTemp, copy_const_string);&lt;BR /&gt;&lt;BR /&gt;        printf("Copied\n");&lt;BR /&gt;&lt;BR /&gt;        memcpy(pszTemp, copy_const_string, 2);&lt;BR /&gt;&lt;BR /&gt;        printf("Out\n");&lt;BR /&gt;        exit(EXIT_SUCCESS);&lt;BR /&gt;}&lt;BR /&gt;# cc +DD64 -o stupid stupid.c&lt;BR /&gt;# ./stupid                   &lt;BR /&gt;pszTemp: 0x0000000000000000&lt;BR /&gt;Copied&lt;BR /&gt;Memory fault(coredump)&lt;BR /&gt;&lt;BR /&gt;And the final word -- from string(3C) [which is where strcpy() lives]:&lt;BR /&gt; WARNINGS&lt;BR /&gt;      The functions strcat(), strncat(), strcpy(), strncpy(), strtok(), and&lt;BR /&gt;      strtok_r() alter the contents of the array to which s1 points.  They&lt;BR /&gt;      do not check for overflow of the array.&lt;BR /&gt;&lt;BR /&gt;      Null pointers for destination strings cause undefined behavior.&lt;BR /&gt;&lt;BR /&gt;(there's more -- but that's the key line).&lt;BR /&gt;&lt;BR /&gt;Undefined behavior means just this -- the behavior is not defined and can be different on different runs, binaries, platforms, etc. Calling strcpy() with NULL as a destination string is just not something you should do. If you want to catch such things in your code - I'd wrap strcpy() in a function or macro and use assert(dest_string != NULL); before the call.&lt;/STRINGS.H&gt;&lt;/STRING.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;&lt;/STRINGS.H&gt;&lt;/STRING.H&gt;&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 03 Apr 2008 15:40:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173460#M321480</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2008-04-03T15:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173461#M321481</link>
      <description>what i meant was the source code was compiled in both platforms with identical options. &lt;BR /&gt;CC compiler versions for both is mentioned in my previous post.&lt;BR /&gt;&lt;BR /&gt;... else it wouldnt execute :)</description>
      <pubDate>Thu, 03 Apr 2008 16:27:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173461#M321481</guid>
      <dc:creator>siba</dc:creator>
      <dc:date>2008-04-03T16:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173462#M321482</link>
      <description>thanks Don,&lt;BR /&gt;&lt;BR /&gt;It was kind of closer to what i need.&lt;BR /&gt;&lt;BR /&gt;and i agree to what you mentioned, but we do have a legacy code which uses strcpy/strcat heavily and changing everything may not be feasible....&lt;BR /&gt;&lt;BR /&gt;i needed it to dump core on IA simular to the PA-RISC systems so that i can capture the same is sighandler and terminate the process...&lt;BR /&gt;&lt;BR /&gt;Guess am shootin in the dark but is there any compiler option that can help me resolve the issue?</description>
      <pubDate>Thu, 03 Apr 2008 16:37:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173462#M321482</guid>
      <dc:creator>siba</dc:creator>
      <dc:date>2008-04-03T16:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173463#M321483</link>
      <description>&amp;gt;&amp;gt; i needed it to dump core on IA simular to the PA-RISC systems so that i can capture the same is sighandler and terminate the process...&lt;BR /&gt;&lt;BR /&gt;I see the words, but I'm having a hard time making sense out of them.&lt;BR /&gt;&lt;BR /&gt;A program which provides a NULL pointer as target for strcpy is broken. What is the point in setting up a mechanism to capture the failure? Fix it! The program _could_ test the result for strcpy.&lt;BR /&gt;&lt;BR /&gt;How about writting your own strcpy? It is not rocket science to get the functionality in place either as a macro, or as a function. To get it optimal is more work.&lt;BR /&gt;&lt;BR /&gt;Hwo about writing a jacket routine with the same name. On first activation have is use dlopen/dlsym to find an address for the read strcpy. Next try to write a byte into the destination pointer. If that works, call the real strcpy through its dyna,icly obtained address (strcpy_pointer). If it fails, then you'll have your signal.&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Apr 2008 17:42:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173463#M321483</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-04-03T17:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: 11.23 IA doesnt dump core during copy into NULL pointer</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173464#M321484</link>
      <description>&amp;gt;i needed it to dump core on IA similar to the PA-RISC systems so that i can capture the same is sighandler and terminate the process.&lt;BR /&gt;&lt;BR /&gt;You are out of luck.  You must add an explicit check or Hein's explicit wrapper.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Guess am shooting in the dark but is there any compiler option that can help me resolve the issue?&lt;BR /&gt;&lt;BR /&gt;Of course not.  While ld's -z will prevent loads from null pointers this is the first I've heard that IPF's strcpy checks BOTH source and target for NULL.</description>
      <pubDate>Fri, 04 Apr 2008 05:12:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/11-23-ia-doesnt-dump-core-during-copy-into-null-pointer/m-p/4173464#M321484</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-04-04T05:12:46Z</dc:date>
    </item>
  </channel>
</rss>

