<?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: Bus Error in assignment. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255214#M332124</link>
    <description>Ok first of all, i'm extremely sorry to provide with such limited amount of information.&lt;BR /&gt;I actually fured out what the problem was.&lt;BR /&gt;&lt;BR /&gt;it starts like this:&lt;BR /&gt;in my header file i've declared 2 structures like this:&lt;BR /&gt;&lt;BR /&gt;#pragma pack 2&lt;BR /&gt;struct A&lt;BR /&gt;{&lt;BR /&gt;    uint16_t i;&lt;BR /&gt;    uint32_t j;&lt;BR /&gt;};&lt;BR /&gt;struct B&lt;BR /&gt;{&lt;BR /&gt;    uint32_t length;&lt;BR /&gt;    uint32_t id;&lt;BR /&gt;    uint8_t buf[16];&lt;BR /&gt;};&lt;BR /&gt;#pragma pack&lt;BR /&gt;&lt;BR /&gt;Now when my function looks like this&lt;BR /&gt;void func()&lt;BR /&gt;{&lt;BR /&gt;    A a;&lt;BR /&gt;    /***** Do Something *****/&lt;BR /&gt;    B b;&lt;BR /&gt;    /****** Do Something *****/&lt;BR /&gt;    int rec_id = b.id; // Line giving SIGBUS&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Now as far as i'm able to interpret the problem is beacuse of the pragma.&lt;BR /&gt;When i declare both the structures with pragma pack 2 i get sizeof(A) as 6 and sizeof(B) as 24.&lt;BR /&gt;Now when make their variables from function stack the memory allocated to A is 6 bytes and while making a variable of B compiler starts using the memory address which is just next to A.&lt;BR /&gt;Which means B will get 2 bytes from one word rest 20 bytes in next 5 words and next 2 bytes from another word. This thing happens beacuse i've set a "pragma pack 2" for B as well, which is actually not required because B is never going to have any padding.&lt;BR /&gt;&lt;BR /&gt;Thus i just modified the header file to this&lt;BR /&gt;#pragma pack 2&lt;BR /&gt;struct A&lt;BR /&gt;{&lt;BR /&gt;    uint16_t i;&lt;BR /&gt;    uint32_t j;&lt;BR /&gt;};&lt;BR /&gt;#pragma pack&lt;BR /&gt;struct B&lt;BR /&gt;{&lt;BR /&gt;    uint32_t length;&lt;BR /&gt;    uint32_t id;&lt;BR /&gt;    uint8_t buf[16];&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;n it works fine now. SIGBUS probably was coming because of misalignment.&lt;BR /&gt;&lt;BR /&gt;But the thing is OLD compilers never gave this kinda problem. So is it a compiler bug or is it that this new compiler has added intelligence in it.&lt;BR /&gt;&lt;BR /&gt;I'm running this code on a PA RISC machine and compiled with aCC compiler version &lt;BR /&gt;"aCC: HP C/aC++ B3910B A.06.21 "&lt;BR /&gt;&lt;BR /&gt;Sorry again that i provided with limited amount of info. This is also just a sample code written above i can not provide with actual snippet.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Thu, 21 Aug 2008 07:35:52 GMT</pubDate>
    <dc:creator>Arun  Grover</dc:creator>
    <dc:date>2008-08-21T07:35:52Z</dc:date>
    <item>
      <title>Bus Error in assignment.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255211#M332121</link>
      <description>&lt;!--!*#--&gt;I've faced a strange error with aCC C++ compiler.&lt;BR /&gt;&lt;BR /&gt;There is a piece of code in which when i try to declare and define an integer (uint32_t) it gives me a BUS ERROR.&lt;BR /&gt;for example:&lt;BR /&gt;uint32_t id = structure.int_variable;&lt;BR /&gt;&lt;BR /&gt;But when i do the same thing by declaring and defining separately  in the following manner there is no error.&lt;BR /&gt;uint32_t id = 0;&lt;BR /&gt;id = structure.int_variable;&lt;BR /&gt;&lt;BR /&gt;I just want to how how does the compiler interpret these statements.</description>
      <pubDate>Wed, 20 Aug 2008 14:00:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255211#M332121</guid>
      <dc:creator>Arun  Grover</dc:creator>
      <dc:date>2008-08-20T14:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255212#M332122</link>
      <description>Have you considered the advantages of posting&lt;BR /&gt;a real failing test case, instead of&lt;BR /&gt;fragments filled with mysteries like&lt;BR /&gt;"structure"?&lt;BR /&gt;&lt;BR /&gt;By the time you explain the problem well&lt;BR /&gt;enough that some non-psychic person can see&lt;BR /&gt;what you're actually doing, the problem may&lt;BR /&gt;become clear to you, too.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] a strange error with aCC C++ compiler.&lt;BR /&gt;&lt;BR /&gt;It's a run-time error, not a compile-time&lt;BR /&gt;error, right?  Showing actual commands with&lt;BR /&gt;actual output can be more helpful than vague&lt;BR /&gt;descriptions, too.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I just want [...]&lt;BR /&gt;&lt;BR /&gt;I'm sure that the compiler can emit the&lt;BR /&gt;actual machine code it generates in a form&lt;BR /&gt;slightly easier to read than a ".o" file, but&lt;BR /&gt;I doubt that that would help you.</description>
      <pubDate>Wed, 20 Aug 2008 15:09:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255212#M332122</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-08-20T15:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255213#M332123</link>
      <description>&lt;P&gt;&amp;gt;I just want to how how does the compiler interpret these statements.&lt;BR /&gt;&lt;BR /&gt;The first is an initialization. The second is an assignment. It they are builtin types, they should do the same thing.&lt;BR /&gt;&lt;BR /&gt;Are you in a thread? A thread stack overflow?&lt;BR /&gt;I assume that structure is a static, global, parm or local object? If it is a reference, that could have a bad pointer value.&lt;BR /&gt;Can you use gdb to print id and structure?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;Steven: I doubt that that would help you.&lt;BR /&gt;&lt;BR /&gt;It would help me. :-)&lt;BR /&gt;&lt;BR /&gt;What version is your aC++ compiler? What OS version and hardware model?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2014 04:01:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255213#M332123</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2014-02-09T04:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255214#M332124</link>
      <description>Ok first of all, i'm extremely sorry to provide with such limited amount of information.&lt;BR /&gt;I actually fured out what the problem was.&lt;BR /&gt;&lt;BR /&gt;it starts like this:&lt;BR /&gt;in my header file i've declared 2 structures like this:&lt;BR /&gt;&lt;BR /&gt;#pragma pack 2&lt;BR /&gt;struct A&lt;BR /&gt;{&lt;BR /&gt;    uint16_t i;&lt;BR /&gt;    uint32_t j;&lt;BR /&gt;};&lt;BR /&gt;struct B&lt;BR /&gt;{&lt;BR /&gt;    uint32_t length;&lt;BR /&gt;    uint32_t id;&lt;BR /&gt;    uint8_t buf[16];&lt;BR /&gt;};&lt;BR /&gt;#pragma pack&lt;BR /&gt;&lt;BR /&gt;Now when my function looks like this&lt;BR /&gt;void func()&lt;BR /&gt;{&lt;BR /&gt;    A a;&lt;BR /&gt;    /***** Do Something *****/&lt;BR /&gt;    B b;&lt;BR /&gt;    /****** Do Something *****/&lt;BR /&gt;    int rec_id = b.id; // Line giving SIGBUS&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Now as far as i'm able to interpret the problem is beacuse of the pragma.&lt;BR /&gt;When i declare both the structures with pragma pack 2 i get sizeof(A) as 6 and sizeof(B) as 24.&lt;BR /&gt;Now when make their variables from function stack the memory allocated to A is 6 bytes and while making a variable of B compiler starts using the memory address which is just next to A.&lt;BR /&gt;Which means B will get 2 bytes from one word rest 20 bytes in next 5 words and next 2 bytes from another word. This thing happens beacuse i've set a "pragma pack 2" for B as well, which is actually not required because B is never going to have any padding.&lt;BR /&gt;&lt;BR /&gt;Thus i just modified the header file to this&lt;BR /&gt;#pragma pack 2&lt;BR /&gt;struct A&lt;BR /&gt;{&lt;BR /&gt;    uint16_t i;&lt;BR /&gt;    uint32_t j;&lt;BR /&gt;};&lt;BR /&gt;#pragma pack&lt;BR /&gt;struct B&lt;BR /&gt;{&lt;BR /&gt;    uint32_t length;&lt;BR /&gt;    uint32_t id;&lt;BR /&gt;    uint8_t buf[16];&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;n it works fine now. SIGBUS probably was coming because of misalignment.&lt;BR /&gt;&lt;BR /&gt;But the thing is OLD compilers never gave this kinda problem. So is it a compiler bug or is it that this new compiler has added intelligence in it.&lt;BR /&gt;&lt;BR /&gt;I'm running this code on a PA RISC machine and compiled with aCC compiler version &lt;BR /&gt;"aCC: HP C/aC++ B3910B A.06.21 "&lt;BR /&gt;&lt;BR /&gt;Sorry again that i provided with limited amount of info. This is also just a sample code written above i can not provide with actual snippet.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 21 Aug 2008 07:35:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255214#M332124</guid>
      <dc:creator>Arun  Grover</dc:creator>
      <dc:date>2008-08-21T07:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255215#M332125</link>
      <description>&lt;P&gt;&amp;gt;in my header file I've declared 2 structures like this:&lt;BR /&gt;&lt;BR /&gt;There are N things terribly wrong here.&lt;BR /&gt;1) This shouldn't abort.&lt;BR /&gt;2) Your compiler version doesn't match your architecture.&lt;BR /&gt;3) You can't possibly have aCC6's A.06.21, it is still under development.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;while making a variable of B compiler starts using the memory address which is just next to A.&lt;BR /&gt;&lt;BR /&gt;While it could do that, it doesn't have to.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;But the thing is OLD compilers never gave this kinda problem.&lt;BR /&gt;&lt;BR /&gt;What was the old version?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I'm running this code on a PA-RISC machine and compiled with aCC&lt;BR /&gt;&lt;BR /&gt;The latest aCC3 version is A.03.85.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2014 04:00:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255215#M332125</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2014-02-09T04:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255216#M332126</link>
      <description>&lt;P&gt;&amp;gt;while making a variable of B compiler starts using the memory address which is just next to A.&lt;BR /&gt;&lt;BR /&gt;Testing A.03.85 indicates it does that. But I can't duplicate the alignment trap.&lt;BR /&gt;What compile options were you using?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2014 04:00:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255216#M332126</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2014-02-09T04:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255217#M332127</link>
      <description>OOps compiler version which i have given is of "ia" i guess. I'll confirm the compiler options and version as soon as i get hold of integration team.&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Aug 2008 15:32:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255217#M332127</guid>
      <dc:creator>Arun  Grover</dc:creator>
      <dc:date>2008-08-22T15:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Bus Error in assignment</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255218#M332128</link>
      <description>&lt;P&gt;&amp;gt;I get hold of integration team.&lt;BR /&gt;&lt;BR /&gt;You might have them or you get a hold of me directly.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Feb 2014 04:00:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/bus-error-in-assignment/m-p/4255218#M332128</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2014-02-09T04:00:44Z</dc:date>
    </item>
  </channel>
</rss>

