Skip to content

RDKEMW-28167: Guard task executors against exceptions - #689

Open
jaihere4u wants to merge 1 commit into
masterfrom
RDKEMW-28167-task-exception-guard
Open

jaihere4u wants to merge 1 commit into
masterfrom
RDKEMW-28167-task-exception-guard

Conversation

@jaihere4u

Copy link
Copy Markdown

Reason for change:
None of the three task executors caught exceptions. A throwing task escaped the thread function and called std::terminate, killing the session-server process - and every session in it - with no error log. On the main thread a thrown exception also skipped the state->done signal, hanging any enqueueTaskAndWait waiter before termination.

MainThread::mainThreadLoop, WorkerThread::taskHandler and EventThread::threadExecutor now catch std::exception and unknown exceptions, log them, and continue the loop. On the main thread the state->done signal still runs after a failed task so waiters are released.

Test Procedure:
Enqueue a throwing task on each executor; verify the process survives, the exception is logged, and enqueueTaskAndWait callers are released. Existing unit tests pass.

Reason for change:
None of the three task executors caught exceptions. A throwing task escaped
the thread function and called std::terminate, killing the session-server
process - and every session in it - with no error log. On the main thread a
thrown exception also skipped the state->done signal, hanging any
enqueueTaskAndWait waiter before termination.

MainThread::mainThreadLoop, WorkerThread::taskHandler and
EventThread::threadExecutor now catch std::exception and unknown exceptions,
log them, and continue the loop. On the main thread the state->done signal
still runs after a failed task so waiters are released.

Test Procedure:
Enqueue a throwing task on each executor; verify the process survives, the
exception is logged, and enqueueTaskAndWait callers are released. Existing
unit tests pass.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 15:09
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Pull request title must follow the pattern:
< JIRA TICKET >: < one line summary of change less than 65 characters >

Pull request description must follow the Commit message format for RDK-E:
https://etwiki.sys.comcast.net/spaces/RDKAR/pages/1407997180/Commit+Message+Format+For+RDKE

  1. Associated JIRA ticket in format : < JIRA TICKET >: < one line summary of change less than 65 characters >
  2. Detailed reason for change information
  3. Test procedure. Only references links to Jira ticket or sub tickets where test steps and references are captured.

< JIRA TICKET >: < one line summary of change less than 65 characters >
< empty line >
Reason for change:
Test Procedure: < https://ccp.sys.comcast.net/browse/JIRA TICKET/url/to/test_step_section>

Copilot AI 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.

🟡 Changes recommended

Active critical issues can leave synchronous callers with uninitialized results or cause worker shutdown and promise-based calls to hang indefinitely.

3 open issues
What changed in this PR

This PR adds exception handling to three task executors so throwing tasks are logged rather than escaping their thread functions and terminating the process.

Changes:

  • Catch standard and unknown exceptions around task execution.
  • Continue processing subsequent tasks after an exception.
  • Preserve main-thread completion notification so synchronous waiters are released.
File Description
media/​server/​main/​source/​MainThread.cpp Catches task exceptions before notifying synchronous waiters.
media/​server/​gstplayer/​source/​WorkerThread.cpp Logs task exceptions and continues the worker loop.
common/​source/​EventThread.cpp Logs callback exceptions and resumes event processing.

Review effort: Balanced

Comment on lines +95 to +97
catch (const std::exception &e)
{
RIALTO_COMMON_LOG_ERROR("Exception thrown by event thread callback: %s", e.what());
Comment on lines +104 to +106
catch (const std::exception &e)
{
RIALTO_SERVER_LOG_ERROR("Exception thrown by task on the worker thread: %s", e.what());
Comment on lines +96 to +98
catch (const std::exception &e)
{
RIALTO_SERVER_LOG_ERROR("Exception thrown by task on the main thread: %s", e.what());
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Coverage statistics of your commit:
WARNING: Lines coverage decreased from: 84.3% to 84.2%
Functions coverage stays unchanged and is: 92.7%

This branch has not been deployed

No deployments
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