<?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: Shared Memory problem (pointer arithmetic) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210635#M496205</link>
    <description>&lt;P&gt;&amp;gt;I'm wondering if shared memory is actually allocated in 1k increments,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would assume it is allocated in terms of pages, at least 4 KB, so should be rounded up by the OS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Brain fart. It's HP-UX 11.31 and was HP-UX 11.23.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use "Post Options &amp;gt; Edit Reply" and nobody will ever know.&amp;nbsp; ;-)&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2013 04:57:35 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2013-09-25T04:57:35Z</dc:date>
    <item>
      <title>Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210503#M496203</link>
      <description>&lt;P&gt;I am working on a program that creates a shared memory segment of 16000 bytes. The program works fine until it tries to write into shared memory at a&amp;nbsp;location past 15k (past 15360), when it crashes with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Execution error : file '&amp;lt;xxx&amp;gt;'&lt;BR /&gt;error code: 114, pc=0, call=1, seg=0&lt;BR /&gt;114&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Attempt to access item beyond bounds of memory (Signal 11)&lt;/P&gt;
&lt;P&gt;or sometimes&lt;/P&gt;
&lt;P&gt;115&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unexpected signal (Signal 4)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I create shared memory with 16385 bytes (16k+1) it's fine. 16k exactly does not work. This is HP UX 15.5 64 bit. The program works under 15.0 32 bit. I can increase the amount of shared memory, but I don't know if that solves it or is&amp;nbsp;just a band-aid that'll bite me later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm wondering if shared memory is actually allocated in 1k increments, and it's having a problem with the amount between 15k and 16000, or something along those lines. Or more generally, is shared memory handled differently between 15.0 and 15.5.&amp;nbsp;I have not found any documentation supporting&amp;nbsp;this. Any thoughts?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S&amp;gt; This thread has been moevd&amp;nbsp;from HP-UX &amp;gt; General to HP-UX &amp;gt; languages. - Hp forum Moderator&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2013 02:33:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210503#M496203</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-26T02:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210523#M496204</link>
      <description>&lt;P&gt;Brain fart. It's HP UX 11.31, and was HP UX 11.23. We compile 64&amp;nbsp;bit apps on the&amp;nbsp;new server,&amp;nbsp;32 bit on the old. The problem happens on the new server. 15.0 and 15.5 are something unrelated that I happened to have up on my screen when I was typing. It's been a long day.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2013 23:06:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210523#M496204</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-19T23:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory problem (pointer arithmetic)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210635#M496205</link>
      <description>&lt;P&gt;&amp;gt;I'm wondering if shared memory is actually allocated in 1k increments,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would assume it is allocated in terms of pages, at least 4 KB, so should be rounded up by the OS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;Brain fart. It's HP-UX 11.31 and was HP-UX 11.23.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can use "Post Options &amp;gt; Edit Reply" and nobody will ever know.&amp;nbsp; ;-)&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 04:57:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6210635#M496205</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-09-25T04:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211101#M496206</link>
      <description>&lt;P&gt;The system aligns the size to next base page-size boundary.&amp;nbsp;&amp;nbsp; The base-page size is usually 4096 unless you have changed it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is unlikely that you can get a signal if the size was 15000 bytes.&amp;nbsp; The system would have aligned it to 16384 bytes (assuming a base-page of 4096).&amp;nbsp;&amp;nbsp; One of the signals you've got is 4 which is SIGILL -- seems to suggest that something else is happening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share your code, if possible ?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2013 11:26:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211101#M496206</guid>
      <dc:creator>Santosh Abraham</dc:creator>
      <dc:date>2013-09-20T11:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211603#M496207</link>
      <description>&lt;P&gt;I can't post the code and stay employeed, but maybe I can work up a smaller sample that does the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This error being a red herring is one of my main concerns. I can increase the size of the shared memory, but if that's covering up something else, it's not fixed.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2013 18:34:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211603#M496207</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-20T18:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory problem (pointer arithmetic)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211617#M496208</link>
      <description>&lt;P&gt;&amp;gt;maybe I can work up a smaller sample that does the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How are you accessing your shared memory from your MF COBOL app?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 04:57:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6211617#M496208</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-09-25T04:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6214337#M496209</link>
      <description>&lt;P&gt;I pulled all the shared memory code out into a separate program, and it, of course, runs fine. So the shared memory segment size is probably covering up the real problem. So I'm on to that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as how the program is accessing shared memory, it's just writing into it with a memcpy. (The cobol routine is calling a C function.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2013 23:10:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6214337#M496209</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-23T23:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory problem (pointer arithmetic)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6214691#M496210</link>
      <description>&lt;P&gt;&amp;gt;it's just writing into it with a memcpy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's the length of the copy?&lt;/P&gt;&lt;P&gt;I assume you know that the source and target can't overlap in any manner?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 04:57:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6214691#M496210</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-09-25T04:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215427#M496211</link>
      <description>&lt;P&gt;It's writing 48 bytes at a time, and theoretically has a few hundred bytes left. I've played with that size, abd&amp;nbsp;the shared memory size in relation to the record size, and gotten no useful info.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Overlap: Yeah, it's nothing that easy. I've dumped addresses all over the place and nothing is close. Plus the same code&amp;nbsp;works fine when recompiled on a 32 bit system.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2013 15:19:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215427#M496211</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-24T15:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215841#M496212</link>
      <description>&lt;P&gt;Found it. It was a very obscure little pointer math problem. Seems that if you have a pointer to a structure and add an integer to it, you get garbage. Then when you write to that address you trash memory. I was trashing a function address that was out past my shared memory range, so the fact that it was shared memory was not relevant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cptr = (void *)2305843009203077152;&amp;nbsp;&amp;nbsp; // cptr is defined as a pointer to a struct of 2 ints, a double, and 2 ptrs&lt;/P&gt;&lt;P&gt;anint = 48;&lt;/P&gt;&lt;P&gt;cptr2 = (void *)(cptr + anint);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // cptr2 is a pointer to the same struct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RESULTS:&lt;BR /&gt;anint2 =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 48&lt;BR /&gt;cptr&amp;nbsp;&amp;nbsp; &amp;nbsp; = 2305843009203077152&lt;BR /&gt;cptr2&amp;nbsp; = 2305843009203078688&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Casting both the address and the int as a long fixed it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2013 21:09:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215841#M496212</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-24T21:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory Problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215913#M496213</link>
      <description>&lt;P&gt;On further reflection (and before anyone else says it :-) it's not garbage, it's adding 48 * the size of the structure, which is expected. I just wasn't looking at it that way. Casting the pointer as a long is what made it work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2013 22:15:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6215913#M496213</guid>
      <dc:creator>kenlt</dc:creator>
      <dc:date>2013-09-24T22:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shared Memory problem (pointer arithmetic)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6216263#M496214</link>
      <description>&lt;P&gt;&amp;gt;It was a very obscure little pointer arithmetic problem. Seems that if you have a pointer to a structure and add an integer to it, you get garbage.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No, this is well defined by the C and C++ Standards.&amp;nbsp; The result of ptoT + N is &amp;amp;ptoT[N] and is the same as&lt;/P&gt;&lt;P&gt;(T*)((char*)ptoT + N * sizeof(T)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;gt;Casting both the address and the int as a long fixed it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The proper fix is to cast the pointer to a char*, then add, then cast back to the right type.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2013 04:55:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shared-memory-problem/m-p/6216263#M496214</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2013-09-25T04:55:55Z</dc:date>
    </item>
  </channel>
</rss>

