title: Segmentation fault in valgrind, but not in actual run
body: <p>My code when run within Valgrind gives a segmentation fault, but when run normally it doesn't. How is this possible?</p>
  
  <p>The culprit piece of code ,as pointed out by valgrind:  </p>
  
  <pre><code>static inline void * Vec_PtrEntry( Vec_Ptr_t * p, int i )
  {
      assert( i &gt;= 0 &amp;&amp; i &lt; p-&gt;nSize );
      return p-&gt;pArray[i];
  }
  </code></pre>
  
  <p>And the message by valgrind:  </p>
  
  <pre><code>Process terminating with default action of signal 11 (SIGSEGV)
  ==3290==  Access not within mapped region at address 0x0
  </code></pre>
  
  <p>Why does this happen, if normally the code runs perfectly? How do I fix this? I need to do some memory profiling of the code.</p>