Opened 8 years ago
Closed 7 years ago
#10727 closed Bugs (fixed)
polymorphic serialization of shared_ptr fails
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost 1.58.0 | Severity: | Regression |
Keywords: | Cc: | dave.lowell@… |
Description
This issue arised in boost 1.56 and got reported here the first time:
http://lists.boost.org/boost-users/2014/08/82735.php
the answer reported this as being a likely duplicate of another fixed bug. I reported the bug later via the mailing list twice(1.56 after code analysis and 1.57 beta1) so now the official bug report to make it more official.
"taking a look at the trac ticket in the answer: https://svn.boost.org/trac/boost/ticket/10348 i came to the conclusion that this is not the same bug. the ticket there reported an error due to missing includes. However, the bug in the polymorphic archives is different as the polymorphic_iarchive class does not derive from detail::helper_collection (however the polymorphic_*_iarchive class do as they derive from *_iarchive via polymorphic_iarchive_rout) and thus a call to ar.template get_helper<T>() will fail when ar is the polymorphic_iarchive class. I am not sure how to fix this easily."
Here is the error:
/include/boost/serialization/shared_ptr.hpp:170:9: error: 'class boost::archive::polymorphic_iarchive' has no member named 'get_helper'
the first link contains already a minimal example to reproduce the error.
I would love to see it fixed prior to 1.57
Change History (15)
comment:1 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Sorry, this is NOT fixed. Please at least pretend to take a look into it.
boost 1.57 fresh checkout on ArchLinux
/home/ulfi/Shark/src/Models/Centroids.cpp:163:1: required from here /usr/include/boost/serialization/shared_ptr.hpp:170:9: error: 'class boost::archive::polymorphic_iarchive' has no member named 'get_helper'
);
comment:3 by , 8 years ago
and a minimal example:
#include <boost/shared_ptr.hpp> #include <boost/archive/polymorphic_text_iarchive.hpp> #include <fstream> #include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/vector.hpp>something to de-serialize int main(){ std::ifstream i("foo");
boost::archive::polymorphic_text_iarchive ia(i); boost::archive::polymorphic_iarchive & ia_interface = ia; boost::shared_ptr<std::vector<int> > p; ia_interface >> p;
}
boost version #define BOOST_VERSION 105700
error
In file included from /home/ulfi/feyidata/main.cpp:6:0: /usr/include/boost/serialization/shared_ptr.hpp: In instantiation of 'void boost::serialization::load(Archive&, boost::shared_ptr<U>&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive; T = std::vector<int>]': /usr/include/boost/serialization/split_free.hpp:58:22: required from 'static void boost::serialization::free_loader<Archive, T>::invoke(Archive&, T&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive; T = boost::shared_ptr<std::vector<int> >]' /usr/include/boost/serialization/split_free.hpp:74:38: required from 'void boost::serialization::split_free(Archive&, T&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive; T = boost::shared_ptr<std::vector<int> >]' /usr/include/boost/serialization/shared_ptr.hpp:187:57: required from 'void boost::serialization::serialize(Archive&, boost::shared_ptr<U>&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive; T = std::vector<int>]' /usr/include/boost/serialization/serialization.hpp:128:27: required from 'void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive; T = boost::shared_ptr<std::vector<int> >]' /usr/include/boost/archive/detail/iserializer.hpp:188:5: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ] /usr/include/boost/archive/detail/iserializer.hpp:410:13: required from 'static void boost::archive::detail::load_non_pointer_type<Archive>::load_standard::invoke(Archive&, const T&) [with T = boost::shared_ptr<std::vector<int> >; Archive = boost::archive::polymorphic_iarchive]' /usr/include/boost/archive/detail/iserializer.hpp:462:28: required from 'static void boost::archive::detail::load_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = boost::shared_ptr<std::vector<int> >; Archive = boost::archive::polymorphic_iarchive]' /usr/include/boost/archive/detail/iserializer.hpp:618:24: required from 'void boost::archive::load(Archive&, T&) [with Archive = boost::archive::polymorphic_iarchive; T = boost::shared_ptr<std::vector<int> >]' /usr/include/boost/archive/polymorphic_iarchive.hpp:107:40: required from 'void boost::archive::polymorphic_iarchive_impl::load_override(T&, int) [with T = boost::shared_ptr<std::vector<int> >]' /usr/include/boost/archive/detail/interface_iarchive.hpp:60:9: required from 'Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = boost::shared_ptr<std::vector<int> >; Archive = boost::archive::polymorphic_iarchive]' /home/ulfi/feyidata/main.cpp:13:21: required from here /usr/include/boost/serialization/shared_ptr.hpp:170:9: error: 'class boost::archive::polymorphic_iarchive' has no member named 'get_helper'
);
comment:4 by , 8 years ago
This fixed on the development branch. Within a couple of days, this will be merged to the master branch so it will appear in version 1.58 of boost. If your need is more urgent, you can tweak your local boost installation in accordance with the code in the development branch. In the case of boost serialization shared_ptr helper, it's pretty easy as it's just a header not involved in the library so you don't have to rebuild boost. That is, just update/add the missing header and you're in business.
comment:5 by , 8 years ago
Could you provide me with a pointer on how to get the required patch? I have not set up a boost development environment and don't know how. But I am eager to test this as our software relies on this working...
comment:6 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
OK - I looked at this more carefully. There were a couple of issues with the update to shared_ptr seriaiization which I addressed. I didn't realized that this is a different one.
The crux of the issue is that polymorphic archives need to be updated to support the new helper functionality. It's not a trivial fix, but it is is doable.
I'll try go the to it soon. Meanwhile I've re-opened this ticket so it doesn't get lost.
Robert Ramey
comment:7 by , 8 years ago
Cc: | added |
---|
comment:8 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
I beiieved I've fixed this now so I'm closing this ticket
comment:9 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Version: | Boost 1.56.0 → Boost 1.58.0 |
comment:10 by , 7 years ago
Hmmm - is there a reason for re-opening this?
I added a specific test for the combination of polymorphic archives and serialization helper. Then I made changes such that this test passed. I have no indication that this is still an issue.
comment:11 by , 7 years ago
what was the change to fix this? I'm wondering if there's a patch that could be applied to fix it in an earlier version of boost.
(this is unrelated to the ticket being reopened)
comment:13 by , 7 years ago
Hi,
I've upgraded from boost 1.55 to boost 1.58 in debian testing; my code[1] compiles successfully with 1.55[2] but now fails with 1.58. Are there any changes required when moving to boost 1.58 from a serialisation perspective? An example of a file not compiling is [3], with the error:
/usr/include/boost/archive/detail/iserializer.hpp:462:28: required from ‘static void boost::archive::detail::load_non_pointer_type<Archive>::invoke(Archive&, T&) [with T = std::vector<boost::shared_ptr<dogen::dia::attribute> >; Archive = boost::archive::polymorphic_iarchive]’ /usr/include/boost/archive/detail/iserializer.hpp:618:24: required from ‘void boost::archive::load(Archive&, T&) [with Archive = boost::archive::polymorphic_iarchive; T = std::vector<boost::shared_ptr<dogen::dia::attribute> >]’ /usr/include/boost/archive/polymorphic_iarchive.hpp:119:48: required from ‘void boost::archive::polymorphic_iarchive_impl::load_override(const boost::serialization::nvp<T>&, int) [with T = std::vector<boost::shared_ptr<dogen::dia::attribute> >]’ /usr/include/boost/archive/detail/interface_iarchive.hpp:60:9: required from ‘Archive& boost::archive::detail::interface_iarchive<Archive>::operator>>(T&) [with T = const boost::serialization::nvp<std::vector<boost::shared_ptr<dogen::dia::attribute> > >; Archive = boost::archive::polymorphic_iarchive]’ ../../../projects/dia/src/serialization/composite_ser.cpp:53:8: required from ‘void boost::serialization::load(Archive&, dogen::dia::composite&, unsigned int) [with Archive = boost::archive::polymorphic_iarchive]’ ../../../projects/dia/src/serialization/composite_ser.cpp:63:101: required from here /usr/include/boost/serialization/shared_ptr.hpp:170:9: error: ‘class boost::archive::polymorphic_iarchive’ has no member named ‘get_helper’ ninja: build stopped: subcommand failed.
Many thanks for your time and for boost serialisation.
Marco
note: pls add protocol as required, blocked by track for some reason.
[1] github.com/DomainDrivenConsulting/dogen [2] travis-ci.org/DomainDrivenConsulting/dogen/builds [3] github.com/DomainDrivenConsulting/dogen/blob/master/projects/dia/src/serialization/composite_ser.cpp
comment:14 by , 7 years ago
After spending some time looking at this, it seems that the version of boost 1.58 in debian will just not work for polymorphic archives - removing polymorphic archives compiles fine, but not otherwise. I ended up building boost 1.59 manually and that seems to have solved my problems.
comment:15 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
OK - so it's fixed in 1.59 - I'll close this ticket
fixed in https://svn.boost.org/trac/boost/ticket/10348