<?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: Question on new() !! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806344#M721133</link>
    <description>Seqof_GSMObjInstance is defined as a struct, not a class.  So instead of:&lt;BR /&gt;&lt;BR /&gt;= new Seqof_GSMObjInstance(); &lt;BR /&gt;&lt;BR /&gt;don't you need:&lt;BR /&gt;&lt;BR /&gt;= new Seqof_GSMObjInstance;&lt;BR /&gt;&lt;BR /&gt;without the "()"?  There is no constructor function to invoke here; you just want to allocate memory for some structure.&lt;BR /&gt;</description>
    <pubDate>Thu, 03 Oct 2002 13:32:11 GMT</pubDate>
    <dc:creator>Chris De Angelis</dc:creator>
    <dc:date>2002-10-03T13:32:11Z</dc:date>
    <item>
      <title>Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806338#M721127</link>
      <description>Compiler being used is aCC -&lt;BR /&gt;HP aC++ B3910B A.01.23&lt;BR /&gt;HP aC++ B3910B A.01.19.02 Language Support Library&lt;BR /&gt;&lt;BR /&gt;We have a struct like this -&lt;BR /&gt;&lt;BR /&gt;struct Seqof_GSMObjInstance&lt;BR /&gt;{&lt;BR /&gt;  long x;&lt;BR /&gt;  char *octets;&lt;BR /&gt;  struct Seqof_GSMObjInstance *next;&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;There is a function which allocated memory for this structure like this -&lt;BR /&gt;&lt;BR /&gt;Seqof_GSMObjInstance * GSMObjInstance_tBin::alloc()&lt;BR /&gt;{&lt;BR /&gt;  Seqof_GSMObjInstance *aPtr = new Seqof_GSMObjInstance();&lt;BR /&gt;  memset(aPtr, 0, sizeof(SeqObjInst) );&lt;BR /&gt; &lt;BR /&gt;  return aPtr;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;The program was compiled on HP-UX 10.20 but run on HP-UX 11.00.&lt;BR /&gt;&lt;BR /&gt;We had a strange problem. The program crashed and we came to know from gdb through the analysis of the core file that, the program crashed at memset(). A portion of the stack trace is -&lt;BR /&gt;&lt;BR /&gt;  (gdb) bt&lt;BR /&gt;  #0  0xc0f30130 in kill () from /usr/lib/libc.1&lt;BR /&gt;  #1  0xc0e95b24 in raise () from /usr/lib/libc.1&lt;BR /&gt;  #2  0xc0e75f38 in _sigaddset () from /usr/lib/libc.1&lt;BR /&gt;  #3  0xc0e70d64 in abort () from /usr/lib/libc.1&lt;BR /&gt;  #4  0xc9081958 in skSigMgmt::_OspSignalWrapper (signum=10) at /vob/osp.src/src/libskel/skel/skSigSensorThr.C:571&lt;BR /&gt;  #5  0xc0d9e6bc in cma__sig_deliver () from /usr/lib/libcma.1&lt;BR /&gt;  #6  0xc0d9eb78 in cma___sig_sync_term () from /usr/lib/libcma.1&lt;BR /&gt;  #7  &lt;SIGNAL handler="" called=""&gt;&lt;BR /&gt;  #8  0xc0e7227c in memset () from /usr/lib/libc.1&lt;BR /&gt;  #9  0x2dd57c in GSMObjInstance_tBin::alloc (this=0x43c1f8dc)&lt;BR /&gt;&lt;BR /&gt; To know, whether the call to new() was succesful, we executed further commands in gdb -&lt;BR /&gt;  (gdb) f 9&lt;BR /&gt;  #9  0x2dd57c in GSMObjInstance_tBin::alloc (this=0x43c1f8dc)&lt;BR /&gt;   (gdb) info locals&lt;BR /&gt;  aPtr = (struct Seqof_GSMObjInstance *) 0x8&lt;BR /&gt;  (gdb) p *(struct Seqof_GSMObjInstance *) 0x8&lt;BR /&gt;  Cannot access memory at address 0x8&lt;BR /&gt;&lt;BR /&gt;From the above output, it is clear that, new() returned a corrupted address (0x8) and that is the reason the program crashed in memset().&lt;BR /&gt;The program does not crash every time in the above place but this has crashed atleast 3 times.&lt;BR /&gt;&lt;BR /&gt;We checked the size of core (around 60MB) and it was much less than the kernel parameter - maxdsiz (200MB) set for the process. That means, the program did have enough memory in the heap.&lt;BR /&gt;&lt;BR /&gt;Any idea, what went wrong in the above program ?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/SIGNAL&gt;</description>
      <pubDate>Sat, 14 Sep 2002 08:41:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806338#M721127</guid>
      <dc:creator>Mahesh Kurse</dc:creator>
      <dc:date>2002-09-14T08:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806339#M721128</link>
      <description>&lt;BR /&gt;I just slapped my developers and sysadmins on Thursday for using an ancient compiler and complaining about the results.&lt;BR /&gt;&lt;BR /&gt;Start here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h21007.www2.hp.com/dev/1,2583,,00.html" target="_blank"&gt;http://h21007.www2.hp.com/dev/1,2583,,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h21007.www2.hp.com/dev/technologies/topic/1,2608,10201,00.html" target="_blank"&gt;http://h21007.www2.hp.com/dev/technologies/topic/1,2608,10201,00.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The latest version of the Compiler is A.03.35! (June 2002)&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sat, 14 Sep 2002 13:47:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806339#M721128</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-14T13:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806340#M721129</link>
      <description>In your memset() call, you invoke sizeof():&lt;BR /&gt;&lt;BR /&gt;    sizeof(SeqObjInst);&lt;BR /&gt;&lt;BR /&gt;Did you mean this instead?&lt;BR /&gt;&lt;BR /&gt;    sizeof(Seqof_GSMObjInstance);&lt;BR /&gt;&lt;BR /&gt;Jack&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Sep 2002 13:22:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806340#M721129</guid>
      <dc:creator>Jack Tan</dc:creator>
      <dc:date>2002-09-16T13:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806341#M721130</link>
      <description>Sorry for the confusion, the parameter passed for memset() is -&lt;BR /&gt;&lt;BR /&gt;memset(aPtr, 0, sizeof(Seqof_GSMObjInstance) );</description>
      <pubDate>Tue, 17 Sep 2002 04:24:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806341#M721130</guid>
      <dc:creator>Mahesh Kurse</dc:creator>
      <dc:date>2002-09-17T04:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806342#M721131</link>
      <description>The code snippet seems okay when placed in a separate program.  Maybe there is memory corruption elsewhere that is revealed by this particular code.  Have you tried stepping through GSMObjInstance_tBin::alloc() while it executes?&lt;BR /&gt;&lt;BR /&gt;To work around the call to memset(), you can use aggregate initialization:&lt;BR /&gt;&lt;BR /&gt;    const Seqof_GSMObjInstance initial = { 0 };&lt;BR /&gt;    Seqof_GSMObjInstance *aPtr = new Seqof_GSMObjInstance();&lt;BR /&gt;    *aPtr = initial;&lt;BR /&gt;&lt;BR /&gt;Jack&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Sep 2002 13:41:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806342#M721131</guid>
      <dc:creator>Jack Tan</dc:creator>
      <dc:date>2002-09-17T13:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806343#M721132</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Me too faced a similar problem. It goes like this. I was allocating memory to a class-pointer in a function and was assigning it to another pointer (of same class) that was passed as an arg of the function. The interesting aspect is it worked fine but gave me runaways at times.&lt;BR /&gt;&lt;BR /&gt;So the memory allocation was directly performed on the pointer that was passwd as an arg and it worked fine.&lt;BR /&gt;&lt;BR /&gt;I would suggest the following modification to your code.&lt;BR /&gt;&lt;BR /&gt;Seqof_GSMObjInstance * GSMObjInstance_tBin::alloc(Seqof_GSMObjInstance **aPtr) &lt;BR /&gt;                                                     { &lt;BR /&gt;                                                     *aPtr = new Seqof_GSMObjInstance(); &lt;BR /&gt;                                                      memset(*aPtr, 0, sizeof(SeqObjInst) ); &lt;BR /&gt;&lt;BR /&gt;                                                      return *aPtr; &lt;BR /&gt;                                                      } &lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Vishal</description>
      <pubDate>Fri, 27 Sep 2002 13:09:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806343#M721132</guid>
      <dc:creator>Vishal Augustine</dc:creator>
      <dc:date>2002-09-27T13:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806344#M721133</link>
      <description>Seqof_GSMObjInstance is defined as a struct, not a class.  So instead of:&lt;BR /&gt;&lt;BR /&gt;= new Seqof_GSMObjInstance(); &lt;BR /&gt;&lt;BR /&gt;don't you need:&lt;BR /&gt;&lt;BR /&gt;= new Seqof_GSMObjInstance;&lt;BR /&gt;&lt;BR /&gt;without the "()"?  There is no constructor function to invoke here; you just want to allocate memory for some structure.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Oct 2002 13:32:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806344#M721133</guid>
      <dc:creator>Chris De Angelis</dc:creator>
      <dc:date>2002-10-03T13:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Question on new() !!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806345#M721134</link>
      <description>Looks like you have general problem with dynamical memory management. Somewhere else in the code you corrupt free memory blocks list and thats why malloc returns sensless value.&lt;BR /&gt;I would bet that you are using the object after deallocating memory.&lt;BR /&gt;&lt;BR /&gt;Check it carefully.&lt;BR /&gt;Good luck&lt;BR /&gt;&lt;BR /&gt;Adam&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Oct 2002 09:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/question-on-new/m-p/2806345#M721134</guid>
      <dc:creator>Adam J Markiewicz</dc:creator>
      <dc:date>2002-10-23T09:35:37Z</dc:date>
    </item>
  </channel>
</rss>

