C++ memory issue with external library -
i worked commercial company, have lots of internal libraries can reused different project. encountered serious memory issue 1 of library strange.
the source code confidential cannot put here, going mock code describe happened me,
there classes defined in library:
class classb { public: ... static classb* acquireinstance(); }; class classa { public: classb* getb() { return m_pb; } bool init(classb* pb); private: classb* m_pb; }; integrated library(static linked) in our project, our code looks this: void foo() { ... classb* pb = classb::acquireinstance(); classa a; a.init(pb); // step function, m_pb assigned pb, ok inside function. assert(pb == a.getb()); // failed }
comments:
the strange thing found: when step init function, address of m_pb (&m_pb) 0x0000ce08, address of m_pb (&a.m_pb) changed 0x0000ce00.
i think byte alignment issue different config between our project , library. not sure,
is there encountered kind of issue before, idea how fix ?
any input appreciated. thank you.
Comments
Post a Comment