[serialization] Really strange error that crashes the application

I'm developing a client/server application using asio for communication and boost::serialization as the means to stream the objects between the two applications. This is on Windows XP with Microsoft Visual Studio 7.1. Everything works fine until this sequence of events happens: 1) The server shuts down gracefully and serializes some classes to a file. 2) The server restarts and reads in the file, loading the settings and replacing the default settings 3) The client makes a request for an object from the server 4) The server dies with the following error: --------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Error! Program: c:\Dev\NwEngineD.exe This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. (Press Retry to debug the application) --------------------------- Abort Retry Ignore --------------------------- Now, if I skip loading of the previously saved file, none of this ever happens. Everything works just fine. The following is the call stack when the error occurs:
msvcr71d.dll!_NMSG_WRITE(int rterrnum=10) Line 195 C msvcr71d.dll!abort() Line 44 + 0x7 C msvcr71d.dll!_assert(const char * expr=0x003696dc, const char * filename=0x00369668, unsigned int lineno=71) Line 306 C boost_serialization-vc71-mt-gd-1_33_1.dll!0033bc2c() boost_serialization-vc71-mt-gd-1_33_1.dll!0033bb70()
NwEngineD.exe!boost::serialization::detail::extended_type_info_typeid_1 ::saveboost::archive::text_oarchive() Line 78 C++ NwEngineD.exe!boost::serialization::access::member_save ::invoke(boost::archive::text_oarchive & ar={...}, const
boost::serialization::nvp NwEngineD.exe!boost::serialization::split_member (boost::archive::text_oarchive & ar={...},
boost::serialization::nvp NwEngineD.exe!boost::serialization::access::serialize (boost::archive::text_oarchive & ar={...},
boost::serialization::nvp NwEngineD.exe!boost::archive::detail::save_non_pointer_type ::save_only::invoke(boost::archive::text_oarchive & ar={...}, const
boost::serialization::nvp NwEngineD.exe!boost::archive::detail::save_non_pointer_type ::invoke(boost::archive::text_oarchive & ar={...}, const
boost::serialization::nvp NwEngineD.exe!boost::archive::save (boost::archive::text_oarchive & ar={...}, const
std::list NwEngineD.exe!boost::serialization::save ::invoke(boost::archive::text_oarchive & ar={...}, const
std::list NwEngineD.exe!boost::serialization::split_free (boost::archive::text_oarchive & ar={...},
std::list NwEngineD.exe!boost::serialization::serialize (boost::archive::text_oarchive & ar={...},
std::list NwEngineD.exe!boost::archive::detail::oserializer ::save_object_data(boost::archive::detail::basic_oarchive & ar={...}, const
void * x=0x0012f644) Line 152 + 0x2b C++
boost_serialization-vc71-mt-gd-1_33_1.dll!0032a2ab()
msvcr71d.dll!_onexit_lk(int (void)* func=0x00000008) Line 119 + 0xd
C
msvcr71d.dll!_unlockexit() Line 541 + 0x7 C
msvcr71d.dll!_onexit(int (void)* func=0x0012edbc) Line 99 + 0x5
C
msvcr71d.dll!_onexit(int (void)* func=0x0012edbc) Line 96 + 0x1b
C
NwEngineD.exe!_onexit(int (void)* func=0x0032aa2e) Line 81 + 0x13
C
0012ecec() NwEngineD.exe!boost::archive::detail::save_non_pointer_type ::save_standard::invoke(boost::archive::text_oarchive & ar={...}, const
std::list NwEngineD.exe!boost::archive::detail::save_non_pointer_type ::invoke(boost::archive::text_oarchive & ar={...}, const
std::list NwEngineD.exe!boost::archive::save () Line 79 C++ NwEngineD.exe!boost::archive::detail::interface_oarchive ,boost::arg<1>,boost::arg<2> > > >() Line 99 C++
<** snip **> The last line of serialization code in the call stack (before the DLLs), is
this:
extended_type_info_typeid_1() :
detail::extended_type_info_typeid_0()
{
self_register(); // add type to type table
}
Seems like the self_register() is failing for some reason.
Now, as I've said, if I don't try to read in the saved file, none of this
occurs. As a matter of fact, if I just run this simple code upon server
startup, the whole error above occurs:
typedef unsigned int Handle;
void Manager::load(const std::string &filename)
{
std::ifstream inFile;
inFile.open(filename.c_str(), std::ios::binary);
boost::archive::text_iarchive archiveFile(inFile);
Handle handle = 0;
ManagerNode node;
archiveFile >> handle;
if (handle != Handle(-1))
{
// comment out the line below and everything works fine
// NOTE: the line below works fine (does not blow up)
// it only causes serialization to fail later.
// Also notice that I don't actually do anything with node,
// it just goes out of scope at procedure end
archiveFile >> node;
}
}
My apologies for not being able to provide a complete working program that
mimics the error. I developed a whole test program to replicate the error,
and of course, it works just fine. It does almost everything the server
program does, except it doesn't use asio. My hope is the code above, call
stack and error message is enough to pinpoint where the problem may be. If
it isn't, please give me a general idea of how to proceed.
Thanks for any help,
Scott

Is any of this implemented in a DLL ? the program is haning up because its trying to register a class that is in the process of being destroyed. Try setting a break poin on the assertion on line 71 of exended_type_info.cpp and try to figure out which class is being register. Set break point on the destructor of that class. This might lead one to the point whereby a destructor is being called while someting is being serialized Robert Ramey
participants (2)
-
Robert Ramey
-
Scott