// Testcase: test_binary_archive_with_map // This Win32-specific test creates a std::map from strings to strings and // then serializes it to a file. We then attempt to desearialize from that // file. On boost_1_45_0 and boost_1_51_0 for Win32 this testcase fails on // our company's secondary build machine. // The call stack is below the code, along with details of the failure #include #include #include #ifdef _WIN32 #pragma warning(disable:4244) #else #warning "This testcase affects MSVC boosts; I can't reproduce it on anything else" #endif #include "boost/serialization/serialization.hpp" #include "boost/serialization/map.hpp" #include "boost/archive/binary_iarchive.hpp" #include "boost/archive/binary_oarchive.hpp" int main() { std::map m1, m2; std::string generator = "abcdefghijklmnopqrstuvwxyz"; for (std::string::size_type i = 0; i < generator.size(); ++i) { m1[&generator[i]] = &generator[i]; } std::ofstream ofs; std::ifstream ifs; { ofs.open("test.cache"); boost::archive::binary_oarchive oarch(ofs); oarch << m1; // To ensure the buffers are empty when we re-open the file, and // that file locks are released ofs.flush(); ofs.close(); } { ifs.open("test.cache"); boost::archive::binary_iarchive iarch(ifs); iarch >> m2; } assert(m1 == m2); return 0; } /* Failure details: At the top of the call stack, std::streamsize s = static_cast(count / sizeof(Elem)); std::streamsize scount = m_sb.sgetn( static_cast(address), s ); if(scount != s) boost::serialization::throw_exception( archive_exception(archive_exception::input_stream_error) ); `scount` is 0, `s` is 8. It's trying to load a size_type, presumably for a string length or a map length. m2 is empty when this exception is thrown, but it isn't always empty. Previous executions of this test actually left data in m2, but that was with std::wstrings and not std::strings. */ /* Call stack: > test_binary_archive_with_map.exe!boost::serialization::throw_exception(const boost::archive::archive_exception & e) Line 37 C++ test_binary_archive_with_map.exe!boost::archive::basic_binary_iprimitive >::load_binary(void * address, unsigned __int64 count) Line 166 + 0x42 bytes C++ test_binary_archive_with_map.exe!boost::archive::basic_binary_iprimitive >::load(boost::serialization::collection_size_type & t) Line 89 C++ test_binary_archive_with_map.exe!boost::archive::load_access::load_primitive(boost::archive::binary_iarchive & ar, boost::serialization::collection_size_type & t) Line 108 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::load_primitive::invoke(boost::archive::binary_iarchive & ar, boost::serialization::collection_size_type & t) Line 363 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::invoke(boost::archive::binary_iarchive & ar, boost::serialization::collection_size_type & t) Line 440 C++ test_binary_archive_with_map.exe!boost::archive::load(boost::archive::binary_iarchive & ar, boost::serialization::collection_size_type & t) Line 593 C++ test_binary_archive_with_map.exe!boost::archive::detail::common_iarchive::load_override(boost::serialization::collection_size_type & t, int __formal) Line 67 C++ test_binary_archive_with_map.exe!boost::archive::basic_binary_iarchive::load_override(boost::serialization::collection_size_type & t, int version) Line 196 C++ test_binary_archive_with_map.exe!boost::archive::binary_iarchive_impl >::load_override(boost::serialization::collection_size_type & t, int __formal) Line 51 C++ test_binary_archive_with_map.exe!boost::archive::detail::interface_iarchive::operator>>(boost::serialization::collection_size_type & t) Line 61 C++ test_binary_archive_with_map.exe!boost::serialization::nvp::load(boost::archive::binary_iarchive & ar, const unsigned int __formal) Line 88 C++ test_binary_archive_with_map.exe!boost::serialization::access::member_load >(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 102 C++ test_binary_archive_with_map.exe!boost::serialization::detail::member_loader >::invoke(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 55 C++ test_binary_archive_with_map.exe!boost::serialization::split_member >(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 70 C++ test_binary_archive_with_map.exe!boost::serialization::nvp::serialize(boost::archive::binary_iarchive & ar, const unsigned int file_version) Line 89 + 0x3c bytes C++ test_binary_archive_with_map.exe!boost::serialization::access::serialize >(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 119 C++ test_binary_archive_with_map.exe!boost::serialization::serialize >(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 70 C++ test_binary_archive_with_map.exe!boost::serialization::serialize_adl >(boost::archive::binary_iarchive & ar, boost::serialization::nvp & t, const unsigned int file_version) Line 132 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::load_only::invoke >(boost::archive::binary_iarchive & ar, const boost::serialization::nvp & t) Line 378 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::invoke const >(boost::archive::binary_iarchive & ar, const boost::serialization::nvp & t) Line 440 C++ test_binary_archive_with_map.exe!boost::archive::load const >(boost::archive::binary_iarchive & ar, const boost::serialization::nvp & t) Line 593 C++ test_binary_archive_with_map.exe!boost::archive::detail::common_iarchive::load_override const >(const boost::serialization::nvp & t, int __formal) Line 67 C++ test_binary_archive_with_map.exe!boost::archive::basic_binary_iarchive::load_override const >(const boost::serialization::nvp & t, int version) Line 71 C++ test_binary_archive_with_map.exe!boost::archive::binary_iarchive_impl >::load_override const >(const boost::serialization::nvp & t, int __formal) Line 51 C++ test_binary_archive_with_map.exe!boost::archive::detail::interface_iarchive::operator>> const >(const boost::serialization::nvp & t) Line 61 C++ test_binary_archive_with_map.exe!boost::serialization::stl::load_collection,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > >,boost::serialization::stl::archive_input_map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >,boost::serialization::stl::no_reserve_imp,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & s) Line 148 C++ test_binary_archive_with_map.exe!boost::serialization::load,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, const unsigned int __formal) Line 60 C++ test_binary_archive_with_map.exe!boost::serialization::free_loader,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >::invoke(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, const unsigned int file_version) Line 59 C++ test_binary_archive_with_map.exe!boost::serialization::split_free,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, const unsigned int file_version) Line 75 C++ test_binary_archive_with_map.exe!boost::serialization::serialize,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, const unsigned int file_version) Line 71 C++ test_binary_archive_with_map.exe!boost::serialization::serialize_adl,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, const unsigned int file_version) Line 132 C++ test_binary_archive_with_map.exe!boost::archive::detail::iserializer,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >::load_object_data(boost::archive::detail::basic_iarchive & ar, void * x, const unsigned int file_version) Line 193 C++ test_binary_archive_with_map.exe!boost::archive::detail::basic_iarchive_impl::load_object(boost::archive::detail::basic_iarchive & ar, void * t, const boost::archive::detail::basic_iserializer & bis) Line 395 C++ test_binary_archive_with_map.exe!boost::archive::detail::basic_iarchive::load_object(void * t, const boost::archive::detail::basic_iserializer & bis) Line 538 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::load_standard::invoke,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(boost::archive::binary_iarchive & ar, const std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t) Line 393 C++ test_binary_archive_with_map.exe!boost::archive::detail::load_non_pointer_type::invoke,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t) Line 440 C++ test_binary_archive_with_map.exe!boost::archive::load,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(boost::archive::binary_iarchive & ar, std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t) Line 593 C++ test_binary_archive_with_map.exe!boost::archive::detail::common_iarchive::load_override,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, int __formal) Line 67 C++ test_binary_archive_with_map.exe!boost::archive::basic_binary_iarchive::load_override,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, int version) Line 71 C++ test_binary_archive_with_map.exe!boost::archive::binary_iarchive_impl >::load_override,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t, int __formal) Line 51 C++ test_binary_archive_with_map.exe!boost::archive::detail::interface_iarchive::operator>>,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > >(std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > > & t) Line 61 C++ test_binary_archive_with_map.exe!main() Line 37 + 0x15 bytes C++ test_binary_archive_with_map.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C test_binary_archive_with_map.exe!mainCRTStartup() Line 371 C kernel32.dll!BaseThreadInitThunk() + 0xd bytes ntdll.dll!RtlUserThreadStart() + 0x21 bytes */