Skip to content

Fix use-after-free on OpcUaServer stop during device teardown#26

Open
alexadereyko wants to merge 1 commit into
mainfrom
fix/tms-server-stop-clean-up
Open

Fix use-after-free on OpcUaServer stop during device teardown#26
alexadereyko wants to merge 1 commit into
mainfrom
fix/tms-server-stop-clean-up

Conversation

@alexadereyko
Copy link
Copy Markdown
Contributor

TmsServer::stop stopped the OpcUaServer (nulling its UA_Server*) before releasing tmsDevice/tmsContext. A device worker thread emitting core events during teardown could still reach the live TmsServerSignal listeners, which call into the already-stopped server -- use-after-free on the null UA_Server* (crash in UA_LOCK).

Reset tmsDevice and tmsContext first so ~TmsServerContext unsubscribes from the core event channel before the server is stopped.

TmsServer::stop stopped the OpcUaServer (nulling its UA_Server*) before
releasing tmsDevice/tmsContext. A device worker thread emitting core
events during teardown could still reach the live TmsServerSignal
listeners, which call into the already-stopped server -- use-after-free
on the null UA_Server* (crash in UA_LOCK).

Reset tmsDevice and tmsContext first so ~TmsServerContext unsubscribes
from the core event channel before the server is stopped.
@alexadereyko alexadereyko self-assigned this May 22, 2026
Copy link
Copy Markdown
Collaborator

@NikolaiShipilov NikolaiShipilov left a comment

Choose a reason for hiding this comment

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

LGTM

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