Type of issue
Current Behavior
NullReferenceException in Opc.Ua.Server.MasterNodeManager.ValidateRolePermissions() method if Opc.Ua.NodeState.ClearChangeMasks() is called while Opc.Ua.Server.CustomNodeManager2.CreateMonitoredItems() is processing.
In this case, the Session property of MonitoredItem is null.
Expected Behavior
No exception attempted while changing nodes during monitoreditem creation.
Steps To Reproduce
It's difficult to reproduce because it's depend on thread synchronization.
Environment
- OS: Windows 11
- Environment: Visual Studio 2022
- Runtime: .NET 4.6.2,
- Nuget Version: 1.05.375.457
- Component: Opc.Ua.Server
- Server: Reference Server
- Client: UA Expert
Anything else?
Suggested solution in Libraries/Opc.Ua.Server/Diagnostics/MonitoredNode.cs :
295 : if (monitoredItem.Session != null && monitoredItem.AttributeId == Attributes.Value && (changes & NodeStateChangeMasks.Value) != 0)
instead of :
295 : if (monitoredItem.AttributeId == Attributes.Value && (changes & NodeStateChangeMasks.Value) != 0)
Type of issue
Current Behavior
NullReferenceException in Opc.Ua.Server.MasterNodeManager.ValidateRolePermissions() method if Opc.Ua.NodeState.ClearChangeMasks() is called while Opc.Ua.Server.CustomNodeManager2.CreateMonitoredItems() is processing.
In this case, the Session property of MonitoredItem is null.
Expected Behavior
No exception attempted while changing nodes during monitoreditem creation.
Steps To Reproduce
It's difficult to reproduce because it's depend on thread synchronization.
Environment
Anything else?
Suggested solution in Libraries/Opc.Ua.Server/Diagnostics/MonitoredNode.cs :
295 : if (monitoredItem.Session != null && monitoredItem.AttributeId == Attributes.Value && (changes & NodeStateChangeMasks.Value) != 0)
instead of :
295 : if (monitoredItem.AttributeId == Attributes.Value && (changes & NodeStateChangeMasks.Value) != 0)