Skip to content

WIP Skip non-hierarchical refs in topological sort#292

Open
andreasebner wants to merge 4 commits intomasterfrom
fix/sort-skip-non-hierarchical-refs
Open

WIP Skip non-hierarchical refs in topological sort#292
andreasebner wants to merge 4 commits intomasterfrom
fix/sort-skip-non-hierarchical-refs

Conversation

@andreasebner
Copy link
Copy Markdown
Collaborator

The topological sort in nodeRefsReady() previously blocked on ALL inverse non-HasTypeDefinition references. This caused deadlocks when two nodes in the same nodeset referenced each other via a non-hierarchical reference type.

Non-hierarchical references do not establish parent-child ordering dependencies. Only inverse hierarchical references (subtypes of HierarchicalReferences i=33) and forward HasTypeDefinition require ordering constraints.

The topological sort in Nodeset_sort() determines the order in which
nodes are added to the server. Previously, nodeRefsReady() treated ALL
inverse references (except HasTypeDefinition) as ordering dependencies.
This caused infinite-loop deadlocks when two nodes in the same nodeset
referenced each other via a non-hierarchical reference type.

Only inverse hierarchical references (subtypes of HierarchicalReferences
i=33) create true parent-child ordering dependencies. Non-hierarchical
references (e.g. HasCondition, HasSubStateMachine) are cross-references
that do not require ordering.

Instead of hardcoding known hierarchical reference type IDs, this fix
introduces an isHierarchicalRef callback in NL_FileContext. The open62541
backend implements this callback by using UA_Server_browseRecursive to
discover all subtypes of HierarchicalReferences from the server's
reference type hierarchy at init time. This makes the check robust
against future OPC UA spec additions and custom hierarchical reference
types from any namespace.
@andreasebner andreasebner force-pushed the fix/sort-skip-non-hierarchical-refs branch from 3e375ab to 8e263a0 Compare February 24, 2026 13:28
@andreasebner andreasebner changed the title Skip non-hierarchical refs in topological sort WIP Skip non-hierarchical refs in topological sort Feb 24, 2026
Some companion specs (IOLink, PNENC, PNRIO) declare ValueRank=1 but
provide scalar default values in the XML. After XML decoding, if the
resulting UA_Variant is scalar but the node's ValueRank requires an
array, set arrayLength=1 to convert the scalar into a valid
one-element array. This avoids BadTypeMismatch from the server's
compatibleValueRankValue() check.
Emit a warning via the NodesetLoader logger when a scalar value is
auto-wrapped into a one-element array. This makes the workaround
visible so users can identify companion spec XML authoring bugs
(missing ListOf* wrapper around the value element).
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.

1 participant