Boost logo

Boost Users :

From: JOAQUIN LOPEZ MU?Z (joaquin_at_[hidden])
Date: 2006-07-23 17:36:09


Bogdan M. ha escrito:
>
> Hi,
>
> I am trying to serialize a multi-indexed container defined as
> below ( I am using boost 1.33.1 ):
[...]
>
> While serializing this container containing ===> several nodes
> with the same key <===, I get an access violation exception
> somewhere deep in the multi_index library.
> Tracing a little bit back the stack I noticed something unusual in
> boost_1_33_1\install\include\boost\multi_index\detail\
> duplicates_iterator.hpp
> in the duplicates_iterator::sync() member function (around line 80):
>
> void sync()
> {
> if(pred(begin_chunk->value,node->value))advance();
> }
>
> This function seems to advance the iterator within a chunk of equal
> keys. However, the if clause does not consider the case where
> node == end. These are exactly the circumstances under which my
> program crashes in 'pred(begin_chunk...)'.
> Changing the if condition into
>
> void sync()
> {
> if( (node != end) && pred(begin_chunk->value,node->value))
> advance();
> }
>
> seems to fix the problem. However, I am not familiar with the
> overall implementation and therefore I cannot tell whether this
> is indeed the cause or whether there are side-effects
> to my patch.
> Has anyone else experienced a situation similar to this one?

Hello Bogdan,

You have certainly spotted a bug in duplicates_iterator.hpp,
and the fix you propose is correct. As it happens, this was
first reported some months ago:

http://lists.boost.org/boost-users/2006/01/16710.php

and the bug was fixed since then in the CVS, in what
will become Boost 1.34. Until that release comes out, your
local fix is perfect. Anyway, in case you can afford it, I
recommend you switch now to the CVS version, as it contains
a few other bugfixes.

> Is there something wrong with my container definition, to
> begin with?

I don't see anything wrong with your container definition.
 
> I really appreciate any feedback.
> Thanks,
> Bogdan

Thank you for using Boost.MultiIndex,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net