Skip to content

Fix SIGILL handler: terminate instead of infinite loop#4094

Open
atobiszei wants to merge 5 commits intomainfrom
atobisze_sigill
Open

Fix SIGILL handler: terminate instead of infinite loop#4094
atobiszei wants to merge 5 commits intomainfrom
atobisze_sigill

Conversation

@atobiszei
Copy link
Copy Markdown
Collaborator

Problem:
The SIGILL handler (onIllegal) called setShutdownRequest(2) and returned. SIGILL is a synchronous signal - the CPU raises it when encountering an illegal instruction. Unlike SIGINT/SIGTERM (asynchronous, delivered between instructions), returning from a SIGILL handler resumes execution at the same faulting instruction. This caused:

  1. An infinite loop: fault -> handler -> return -> same fault -> ...
  2. The process appeared "hanged" and had to be kill -9d

🛠 Summary

JIRA/Issue if applicable.
Describe the changes.

🧪 Checklist

  • Unit tests added.
  • The documentation updated.
  • Change follows security best practices.
    ``

…loop

Problem:
The SIGILL handler (onIllegal) called setShutdownRequest(2) and returned.
SIGILL is a synchronous signal - the CPU raises it when encountering an
illegal instruction. Unlike SIGINT/SIGTERM (asynchronous, delivered between
instructions), returning from a SIGILL handler resumes execution at the
same faulting instruction. This caused:
1. An infinite loop: fault -> handler -> return -> same fault -> ...
2. The process appeared "hanged" and had to be kill -9d
@atobiszei atobiszei marked this pull request as ready for review April 2, 2026 14:31
Copilot AI review requested due to automatic review settings April 2, 2026 14:31
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

Updates OVMS server signal handling to avoid an infinite fault/handler loop on synchronous SIGILL by terminating the process immediately after reporting the error.

Changes:

  • Replace SIGILL handler logic to write a minimal diagnostic message and exit immediately.
  • Remove the (now-unreachable) post-loop log that depended on shutdown_request == 2.

atobiszei and others added 2 commits April 3, 2026 10:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@atobiszei atobiszei requested review from dtrawins and rasapala April 3, 2026 08:31
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

Successfully merging this pull request may close these issues.

2 participants