Skip to content

Fix for the wrong return value of lf_check_deadline#559

Merged
edwardalee merged 7 commits intomainfrom
fix-check-deadline
Apr 14, 2026
Merged

Fix for the wrong return value of lf_check_deadline#559
edwardalee merged 7 commits intomainfrom
fix-check-deadline

Conversation

@byeonggiljun
Copy link
Copy Markdown
Collaborator

This PR fixes an error that lf_check_deadline() with the argument invoke_deadline_handler of false returns false even if the reaction has passed the deadline.

Copy link
Copy Markdown
Member

@hokeun hokeun left a comment

Choose a reason for hiding this comment

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

Thanks for spotting and fixing this error!

@hokeun
Copy link
Copy Markdown
Member

hokeun commented Feb 10, 2026

There is one Python test failing, "Failed: src/DeadlineAnytime.lf in 0.04 seconds" which could be caused by this change, but there is a chance that the error is in the test rather than this PR's change.

@byeonggiljun
Copy link
Copy Markdown
Collaborator Author

byeonggiljun commented Feb 11, 2026

The error message is ERROR: check_deadline() returned true when there is no deadline.

I think this is the issue caused by this PR's change.
The problem is that check_deadline() returns true inside the reaction without any deadline now. This is because the if statement below is true if there is no deadline (it seems like the default deadline value is 0).

if (lf_time_physical() > (lf_time_logical(((self_base_t*)self)->environment) + reaction->deadline)) {

I think one solution is as follows, assuming that reaction->deadline_violation_handler is NULL if the reaction has no deadline.

  if (lf_time_physical() > (lf_time_logical(((self_base_t*)self)->environment) + reaction->deadline)) {
    if (reaction->deadline_violation_handler != NULL) {
      if (invoke_deadline_handler) {
        reaction->deadline_violation_handler(self);
      }
      return true;
    }
  }

Copilot AI review requested due to automatic review settings April 13, 2026 00:34
@edwardalee edwardalee enabled auto-merge April 13, 2026 00:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes lf_check_deadline() so it reports whether the currently executing reaction has missed its deadline even when invoke_deadline_handler is false.

Changes:

  • Refactors lf_check_deadline() to separate “deadline passed” from optional handler invocation.
  • Adjusts control flow so the function can return true even when the handler is not invoked.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@edwardalee edwardalee added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Apr 14, 2026
@edwardalee edwardalee merged commit 2ccb557 into main Apr 14, 2026
56 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants