Boost serialization (bug?) issue with MSVC, with vector<shared_ptr> in several libraries
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start with the linked Visual Studio solution and reproduce deserialization on MSVC using ClassTest, ClassBase, and the two vector<shared_ptr> members. Compare the XML output and tracking_level values with the working Linux or explicitly registered-ClassBase case. Done means the described Windows serialization round trip succeeds without requiring unexplained changes to the reproduction.
Written by the indexing model from the issue text.
Description
We use boost serialization in ours projects, both on linux (gcc) and Windows. We encounter a problem only on Windows (for "every" versions of Windows (7 and 10) and of MSVC: Visual 2010 and 2015, ie. MSVC++ 10.0 _MSC_VER == 1600 or MSVC++ 14.0 _MSC_VER == 1900).
Here is the problem summarized: When I serialize a class
- which have base class
- and have 2 vector of shared_ptr of ClassB, with the same contents, and B inherits from the same base class
the serialization works, but the deserialization doesn't ("input stream error").

It's very strange:
- if I remove the base class, it works.
- if I inline the serialization code (empty function) of the base class, it works.
- if the 2 vectors don't have the same content, it works !!
- if I register the ClassBase in the serialize method of ClassTest, it works. I.e.:
// in ClassTest:
template <class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar.template register_type<ClassBase>();
...
}
Some details
When it works on linux, and when it works on Windows with ClassBase type registration in the archive, we have the same xml output.
It's worth noting that:
- boost_serialization is version 17 on Windows and 9 on linux (I didn't tried to update boost on linux yet).
- On BaseClass xml tag, the tracking_level="1", so we have object_id.
And when it doesn't work (once again: the serialization of ClassTest is OK, but cannot deserialized "input stream error"):
- The main difference is in the serialization of ClassTest: the ClassBase part has no tracking_level.
- However it's not the only cause, because if the vectors are differents (same 2 first items, and a third item in one vector), tracking_level of ClassBase in ClassTest part is "0".
I've posted a visual studio solution here.
Thanks a lot for your help. And if any clarification is needed, I'm available of course !
N.B.: I compiled with the last development version of boost serialization, the issue remains.
- Dominant language
- C++
- Stars
- 135
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/serialization
-
infinity Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
boostorg/serialization#386 · 1 comment ·
-
waiting-for-input
Difficulty 5/5 Over a week Newbie friendliness 15/100
boostorg/serialization#331 · 1 comment ·
All issues in boostorg/serialization
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
NVIDIA/cuda-samples#453 ·