[serialization] Problem with multiple multi-index keys.
Hi,
I'm having a problem serializing a multi-index container. Serialization
used to work fine, until I added a second (non-unique) key to the
container. I've managed to distill the problem down to a small bit of
code, so here it is. Uncomment the #define to see the segfault at
serialization time in action, leave it commented and the example code
works fine. I'm clearly missing something subtle (or not-so-subtle) here,
but I don't have the first clue what it might be. Suggestions are
enormously appreciated.
Regards,
tob
----------------------------------------------------------------------------
// A simple program to illustrate my crazy serialization problem with
// multi-index containers. Compiled with:
// g++ -I/usr/local/include/boost-1_33_1/ boost_test.c++ \
// -lboost_serialization -o boost_test
//
// When two keys are specified for FooSet, serialization segfaults. When
// only one key is present, we're fine. Uncomment the line below to see
// the segfault in action.
// #define KILL_SERIALIZATION
#include <fstream>
#include <string>
#include
FooSet;
void save(const FooSet& fooSet) { std::ofstream ofs("foo"); boost::archive::text_oarchive oa(ofs); oa << fooSet; } int main(int argc, char** argv) { FooSet foo_set; foo_set.insert(Foo(100)); foo_set.insert(Foo(150)); save(foo_set); return 0; }
Hello Tob, Toby Smith ha escrito:
Hi,
I'm having a problem serializing a multi-index container. Serialization used to work fine, until I added a second (non-unique) key to the container. I've managed to distill the problem down to a small bit of code, so here it is. Uncomment the #define to see the segfault at serialization time in action, leave it commented and the example code works fine. I'm clearly missing something subtle (or not-so-subtle) here, but I don't have the first clue what it might be.
You're not missing anything, rather you have found a bug in Boost.MultiIndex. Could you please replace line 80 in boost/multi_index/detail/duplicates_iterator.hpp if(pred(begin_chunk->value,node->value))advance(); with the following: if(node!=end&&pred(begin_chunk->value(),node->value()))advance(); and check out if this is fixing the problem in your original code? (The snippet you sent I have already checked out.) I'll be commiting this change to the CVS shortly, thank you very much for spotting the problem and reporting about it. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Hi Joaquin, I rebuilt our full project with this fix, and everything's working perfectly again. Thanks so much for the quick investigation and response! Best regards, tob On Jan 31, 2006, at 3:47 AM, Joaquín Mª López Muñoz wrote:
Hello Tob,
Toby Smith ha escrito:
Hi,
I'm having a problem serializing a multi-index container. Serialization used to work fine, until I added a second (non-unique) key to the container. I've managed to distill the problem down to a small bit of code, so here it is. Uncomment the #define to see the segfault at serialization time in action, leave it commented and the example code works fine. I'm clearly missing something subtle (or not-so- subtle) here, but I don't have the first clue what it might be.
You're not missing anything, rather you have found a bug in Boost.MultiIndex. Could you please replace line 80 in boost/multi_index/detail/duplicates_iterator.hpp
if(pred(begin_chunk->value,node->value))advance();
with the following:
if(node!=end&&pred(begin_chunk->value(),node->value()))advance();
and check out if this is fixing the problem in your original code? (The snippet you sent I have already checked out.) I'll be commiting this change to the CVS shortly, thank you very much for spotting the problem and reporting about it.
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Joaquín Mª López Muñoz
-
Toby Smith