Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONOutputArchive destructor is not really noexcept(true) despite it's declared noexcept(true) #822

Open
Poshjark opened this issue May 20, 2024 · 0 comments

Comments

@Poshjark
Copy link

Poshjark commented May 20, 2024

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.

@Poshjark Poshjark changed the title JSONOutputArchive destructor is not really noexcept(true) though it's declared noexcept(true) JSONOutputArchive destructor is not really noexcept(true) despite it's declared noexcept(true) May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant