title: Derived class vtable corrupted?
body: <h2>Need help in root causing a vtable corruption issue(not sure if that’s what is happening). Here is the very simplified version of the code.</h2>
  
  <pre><code>class CBase
  {
  public:
      CBase()
      virtual ~CBase()
      virtual void base_virtual_fn1() = 0;
      virtual void base_virtual_fn2();
  private:
      CData   _data;
  };
  
  class CDerived : public CBase
  {
  public:
      CDerived();
      virtual ~CDerived()
      virtual void base_virtual_fn1();
      virtual void base_virtual_fn2();
      virtual void derived_virtual_fn1();
      virtual void derived_virtual_fn2();
  private:
      // Contains vectors , maps, integers, bools. 
  };
  </code></pre>
  
  <p>When I create an instance of CDerived and call the derived class virtual function say derived_virtual_fn2  the other function gets called i.e. derived_virtual_fn1.</p>
  
  <p>Calls to base_virtual_fnx has no issues.  </p>
  
  <p>This only happens with object created on the heap and not for local object.</p>
  
  <p>These classes are in a shared library. I’m using gcc 3.4.2 on Linux (SLES 10). There is no pragma pack directive in any of this code and there is a mix of C and C++ code (extern c is used).
  What could be the issue here?</p>
  
  <p>I forgot to mention that there are there is tons of other code (executable, libraries)</p>