Skip to content

[TESTONLY] Proposal terminate vs precondition#677

Draft
yolani wants to merge 1 commit into
eclipse-score:mainfrom
yolani:cvlf/replace_termintate
Draft

[TESTONLY] Proposal terminate vs precondition#677
yolani wants to merge 1 commit into
eclipse-score:mainfrom
yolani:cvlf/replace_termintate

Conversation

@yolani

@yolani yolani commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Do not merge, PR is only used to discuss future changes.

@limdor limdor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some thoughts

{
score::mw::log::LogFatal("lola") << "MessagePassingClientCache: Cannot close connection to target "
<< target_node_id << " in reasonable time";
// no precondition but a runtime error in QNX message passing service --> keep std::terminate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. Even though this could be seen as a postcondition violation. It depends on the functionality of Stop and the expectations of RemoveMessagePassingClient. According to the Stop documentation

/// \brief Stop the existing connection
it seems to imply that it will be stoped after the return but looking at the implementation that does not seem the case. What Stop seems to do to me, is a stop request that might succeed or fail.
Then here we keep getting the state to see if at some point stops, but if not we terminate.
I would leave it as it it with a terminate but improve the API documentation for RemoveMessagePassingClient and Stop.

{
score::mw::log::LogFatal("lola") << "MessagePassingService: Failed to start listening on " << service_identifier
<< " with following error: " << result.error();
// no precondition but a runtime error in QNX message passing service --> keep std::terminate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. But imho similar to the other case, it goes direction postcondition violation that we decided that if we do not fulfill the postcondition our reaction is to terminate.
It seems that in the constructor of MessagePassingServiceInstance we want to guarantee that we will be listening but we are failing to do that.

<< "Service discovery lost at least one event and is compromised now. Bailing out!";
// Potential optimization: Resync the full service discovery with the file system and update all ongoing
// searches with potential changes.
// no precondition, this is a runtime error caused by kernel or filesystem issues / faulty configuration --> keep std::terminate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, not a precondition

mw::log::LogFatal("lola")
<< "Directory" << GetSearchPathForIdentifier(enriched_instance_identifier) << "/" << event.GetName()
<< "was deleted. Outside tampering with service discovery. Aborting!";
// no precondition, this is a runtime error caused by kernel or filesystem issues / faulty configuration --> keep std::terminate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, no precondition

{
mw::log::LogFatal("lola") << "Outside tampering! Bailing! Failed to remove flag file"
<< flag_file_path.Native() << ":" << flag_file_result.error();
// no precondition but runtime error caused by issues in the filesystem --> keep std::terminate()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say, it depends on the error. There are a lot of reasons why a remove can fail. To me how the check is currently written is too brute force. In the case of "not existing" error, that could be a precondition of the destructor that if is_offered the file must exist. It would not be a precondition based on inputs but based on invariants.

<< "into map. Terminating.";
std::terminate();
}
SCORE_LANGUAGE_FUTURECPP_ASSERT_PRD_MESSAGE(insert_result.second,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is a precondition, but I would phrase the message differently. AFAIK insert can only return false if the element was already in the map. I would phrase the precondition failure in that terms. "shm object handle already in the map, that was not expected"

<< "service element makes no sense. Something has gone wrong! Terminating.";
std::terminate();
}
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

<< element_type;
std::terminate();
}
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

<< "Invalid call to GetMessagePassingCfg with asil_level B although app/process is configured for QM only.";
std::terminate();
}
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

"doesn't contain a LoLa deployment!";
std::terminate();
}
SCORE_LANGUAGE_FUTURECPP_PRECONDITION_PRD_MESSAGE(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants