JSONOutputArchive destructor is not really noexcept(true) despite it's declared noexcept(true)
Poshjark opened this issue · 0 comments
According to the code destructor of JSONOutputArchive
can be noexcept
explictly . But no matter defined CEREAL_NOEXCEPT
or not according to to cppreference it's noexcept(true)
implicitly.
But in fact desctructor's code is not noexcept:
//! Destructor, flushes the JSON
~JSONOutputArchive() CEREAL_NOEXCEPT
{
if (itsNodeStack.top() == NodeType::InObject)
itsWriter.EndObject();
else if (itsNodeStack.top() == NodeType::InArray)
itsWriter.EndArray();
}
Causers are rapidjson::Writer::EndObject
and rapidjson::Writer::EndArray
methods that may throw exceptions. For example at the moment when destructor is called stream(nested to writer) to write in can be closed or in invalid state(e.g. zero space on disk if using filestream). And in particular cases it can lead to exception throwing.
This defect makes JSONOutputArchive unsafe to use if system can be heavy loaded(e.g. highloaded servers) because user's code(my) looses opportunity to handle such situations.