segfault happens when I serialize nested class in apache module

ぃ、小莉子 提交于 2019-12-24 07:46:36

问题


Serializing simple class "A" in Apache module done without error but when I tried to serialize my complex object like "X" which has a member, type of "A", I got segfault in Apache module. ( this doesn't happen to a executable console application )

------------------------- here is my code : ---------------------

class A {
private:
    friend class boost::serialization::access; // to enable boost "access" class to call private "serialize" method of class "A"
    template<class ArchT>
    void serialize(ArchT &ar, unsigned int version) {   // method for both serializing and deserializing
        ar & memA; // (de)serialize member "memA"
    }
    std::string memA; // sample member
public:
    A(){}
    A(std::string pmemA) :
        memA(pmemA) {
    }
    std::string GetMemA()
    {
        return memA;
    }
};
class X {

private:
    friend class boost::serialization::access;
    template<class ArchT>
    void serialize(ArchT &ar, unsigned int version) {
        ar & memX;
        ar & a;
    }
    std::string memX;
    A a;
public:
    X(std::string pmemX, A pa) :
        memX(pmemX), a(pa) {
    }
    X(){}

};
-------------------
                        string st=GetRandomFileName();
            ofstream out(st.c_str());
            boost::archive::text_oarchive out_r(out);
            A a("Amem");
            X x("Xmem", a);
            out_r << x; // not works
                        out_r << a; // works!

------------------- here is stack trace from gdb for apache ----------------

boost::serialization::typeid_system::extended_type_info_typeid_0::is_less_than(boost::serialization::extended_type_info const&) const () from /tmp/libIRSProWebApacheModule.so

2 0xb7223c61 in std::_Rb_tree

来源:https://stackoverflow.com/questions/11643402/segfault-happens-when-i-serialize-nested-class-in-apache-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!