Port session activation race condition fix from master378 to master#3846
Merged
Conversation
…ession expires before activation
|
|
Copilot
AI
changed the title
Port fixes from PR #3844 to master: Fix NRE in ActivateSession
Port session activation race condition fix from master378 to master
Jun 5, 2026
Copilot created this pull request from a session on behalf of
romanett
June 5, 2026 09:12
View session
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3846 +/- ##
==========================================
- Coverage 72.74% 72.73% -0.01%
==========================================
Files 913 913
Lines 148285 148286 +1
Branches 25662 25663 +1
==========================================
- Hits 107863 107854 -9
- Misses 31067 31077 +10
Partials 9355 9355
🚀 New features to boost your workflow:
|
marcschier
approved these changes
Jun 5, 2026
marcschier
marked this pull request as ready for review
June 13, 2026 15:58
…annelIdInvalid on reconnect PR #3844 explicitly warned that removing the ActivateSession bypass from SessionManager.ValidateRequestAsync (and the matching guard in Session.ValidateRequest) causes the secure channel id check in Session.ValidateRequest to run on reactivation, breaking valid OPC UA reconnect-on-alternate-channel scenarios (e.g. ApplicationCertificateRotationRehandshakesOpenManagedChannelsAsync, ReconnectJWTAsync, ReconnectSessionOnAlternateChannelAsync). Keep only the StandardServer.cs null-guard from #3844, which is the actual race-condition fix.
marcschier
added a commit
that referenced
this pull request
Jun 15, 2026
Single upstream commit: 03ed5c8 'Port session activation race condition fix from master378 to master (#3846)' — touches Libraries/Opc.Ua.Server/Server/StandardServer.cs only. Auto-merged cleanly with this branch's StandardServer.cs changes (ServerBase constructor + TransportBindingRegistry parameter wiring). Build verified: 'dotnet build UA.slnx -c Debug -p:CustomTestTarget=net10.0' succeeds with 0 errors.
marcschier
added a commit
to marcschier/UA-.NETStandard
that referenced
this pull request
Jul 9, 2026
Brings in 4 upstream commits: OPCFoundation#3879 (dotnet format sweep — whitespace + IDE + RCS), OPCFoundation#3884 (re-enable FuzzCrashAssets + harden BinaryDecoder), OPCFoundation#3846 (port session activation race fix from master378), and OPCFoundation#3745 (split MigrationGuide.md, add What's New in 2.0, rewrite Profiles.md). No textual merge conflicts. The format sweep (OPCFoundation#3879) tightened the repo-root Roslynator analyzer configuration, which newly flagged 27 pre-existing UaLens style sites across 14 files (RCS1078 use string.Empty, RCS0031 enum member on own line, RCS1089 use ++ operator, RCS1006/RCS1061 merge if/else, RCS1031 remove unnecessary braces, RCS1051 remove parentheses, RCS0061 remove blank line between switch sections). Auto-fixed via `dotnet format analyzers` (matching how upstream applied the sweep) plus one manual RCS0061 fix in HistorianPlugin that surfaced after the brace removal. UaLens build clean: 0 errors. The 16 remaining warnings are upstream NuGet TFM notices (Microsoft.Extensions.* 10.6.0 not supporting net48/net472 via Opc.Ua.Gds.Client.Common), unrelated to UaLens. Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a null reference exception that occurs when a session expires between
CreateSessionandActivateSessionrequests. The issue stems from a race condition where the server doesn't properly validate session existence during activation when the session has already timed out.The fix is a minimal, targeted change in
StandardServer.ActivateSessionAsync: a null-coalescing throw ensures the session exists after lookup, returningBadSessionIdInvalidif it has expired.Example flow that previously failed:
Note on scope
Earlier revisions of this port also modified
SessionManager.ValidateRequestAsync(removingActivateSessionfrom the early-return bypass) andSession.ValidateRequest(allowingActivateSessionon non-activated sessions). These changes were reverted because they cause the secure channel id check inSession.ValidateRequestto run on reactivation, breaking valid OPC UA reconnect-on-alternate-channel scenarios — the same regression flagged in the source PR #3844. Symptoms includedBadSecureChannelIdInvalidfailures in tests such asApplicationCertificateRotationRehandshakesOpenManagedChannelsAsync,ReconnectJWTAsync, andReconnectSessionOnAlternateChannelAsync.Related Issues
Ports the fix from PR #3844 which addressed this issue on the master378 branch.
Checklist