当我在apache模块中序列化嵌套类时发生了segfault

时间:2012-07-25 05:40:58

标签: serialization boost apache-modules

在Apache模块中序列化简单类“A”没有错误但是当我尝试序列化我的复杂对象如“X”时,它有一个成员,类型为“A”,我在Apache模块中得到了段错误。 (这不会发生在可执行的控制台应用程序中)

-------------------------这是我的代码:----------------- ----

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!

-------------------这是来自gdb的堆栈跟踪apache ----------------

来自/tmp/libIRSProWebApacheModule.so的

boost :: serialization :: typeid_system :: extended_type_info_typeid_0 :: is_less_than(boost :: serialization :: extended_type_info const&amp;)const()

2 std :: _ Rb_tree中的0xb7223c61

0 个答案:

没有答案