Opened 5 years ago

Closed 5 years ago

#13050 closed Bugs (fixed)

Serialization Fails on Optional Vector

Reported by: cristall@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.64.0 Severity: Regression
Keywords: Cc:

Description

When serializing a boost::optional with T = std::vector, it will fail to load. This is a regression in Boost 1.64 as 1.63 does not appear to exhibit the issue.

The following code will exhibit the issue:

boost::optional<std::vector<std::uint8_t>> opt{};
std::string in_str{ "22 serialization::archive 15 0 0 1 0 4 0 0 1 2 3" };
std::istringstream iss{in_str};
boost::archive::text_iarchive ia{iss};
ia >> opt;

This should set opt to a valid optional containing a vector of {0, 1, 2, 3}. However it will instead either segfault or enter an infinite loop.

The cause appears to be related to a change in boost/serialization/optional.hpp, where stack storage was changed from using detail::stack_construct to detail::stack_allocate. The error appears to come from trying to use an undefined vector object.

This was only tested on OSX using the following:

Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix

Change History (2)

comment:1 by anonymous, 5 years ago

It seems this may be already be fixed in the latest serialization lib based on this commit:

https://github.com/boostorg/serialization/commit/632df7aab5e1fb3458ea53be2704c83462b2caa9

comment:2 by Robert Ramey, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.