title: Core dump when trying to access a pointer to a structure passed to a function in solaris
body: <p>I have a quite complicated code in that is working fine on AIX but core dumping in Solaris. I tried to make it as simplified as possible.</p>
  
  <p>Below is a global structrue having a pointer to a function</p>
  
  <pre><code> custom_struct_1 my_struct1 = {
        intValue1, intValue2, intValue3, func3
     };
  </code></pre>
  
  <p>This is a second structure having a pointer to the first one as a field</p>
  
  <pre><code>  custom_struct_2 my_struct2 = {
        intValue1, intValue2, &amp;my_struct1
    };
  </code></pre>
  
  <p>below is the flow</p>
  
  <pre><code>func1(){
  
     custom_struct *my_dumping_struct;
     memset(my_struct, 0, sizeof(my_struct);
  
     func2(my_dumping_struct, &amp;my_struct2);
  
  
   }
  
  func2(custom_struct *my_dumping_struct, custom_struct_2 *my_struct2 ){
  
     custom_struct1 *my_cust1;
     // Some conditions go here 
  
     my_cust1 = &amp;my_struct2-&gt;custom_struct_1;
  
     my_cust1-&gt;struct_func(my_dumping_struct);
  
  }
  
  
  func3(custom_struct *my_dumping_struct)
  {
      // Here when trying to access any field of the passed structure
      // a core dump is occuring
      if(my_dumping_struct-&gt;intValue1 == 0)
      {
          ....
      }
  }
  </code></pre>
  
  <p>I appreciate any help. It is driving me crazy. I tried multipile things like defining the dumping structure without a pointer at first, using </p>
  
  <pre><code>  memset(&amp;my_dumping_structre, 0, sizeof(my_dumping_struct))
  </code></pre>
  
  <p>and passing it with a reference to the other functions it still core dumps.</p>
  
  <p><em>EDIT</em></p>
  
  <p>Definition of the structures are as below:</p>
  
  <pre><code> struct custom_struct {
              int intValue1;
              int intValue2;
           };
  
           struct custom_struct_1 {
  
              int intValue1;
              int intValue2;
              int intValue3;
              int (*struct_func)(custom_struct *my_struct);
           };
  
           struct custom_struct_2 {
              int intValue1;
              int intValue2;
              struct custom_struct_1 *my_struct;
           };
  </code></pre>
  
  <p>Thanks</p>