Skip to content

Initialize encoder fuzz ServiceMessageContext (OPC 10000-6)#4035

Open
marcschier wants to merge 3 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/encoder-fuzz-context
Open

Initialize encoder fuzz ServiceMessageContext (OPC 10000-6)#4035
marcschier wants to merge 3 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/encoder-fuzz-context

Conversation

@marcschier

Copy link
Copy Markdown
Collaborator

Failure

The encoder fuzz host relied on NUnit or corpus-tool setup to assign
FuzzableCode.MessageContext. Direct afl-fuzz/libFuzzer startup could therefore
reach encoder targets without an initialized OPC UA message context.

Fix

  • Initialize one process-lifetime ServiceMessageContext with null logging.
  • Make the context immutable and remove test/tool reassignment.
  • Exercise the same context from regression tests and the standalone fuzz host.

Reference

Tests

  • dotnet test fuzzing\Opc.Ua.Encoders.Fuzz.Tests\Opc.Ua.Encoders.Fuzz.Tests.csproj -c Release -f net10.0 --nologo (4,569 passed)
  • dotnet run --project fuzzing\Opc.Ua.Encoders.Fuzz\Opc.Ua.Encoders.Fuzz.csproj -c Release -- (standalone smoke passed)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 10:42
Copilot AI review requested due to automatic review settings July 19, 2026 10:42

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.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR ensures the encoder fuzz host always has an initialized OPC UA ServiceMessageContext even when started directly (e.g., afl-fuzz/libFuzzer), by moving initialization into the fuzz target code and removing test/tool reassignment.

Changes:

  • Initialize a single process-lifetime ServiceMessageContext in FuzzableCode using a null-logging telemetry context.
  • Remove prior test/tool setup that reassigned FuzzableCode.MessageContext.
  • Add a regression test asserting MessageContext is available without per-test setup.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
fuzzing/Opc.Ua.Encoders.Fuzz/FuzzableCode.cs Adds default, process-lifetime ServiceMessageContext initialization using null logging telemetry.
fuzzing/Opc.Ua.Encoders.Fuzz.Tools/Encoders.Testcases.cs Stops reassigning the global message context; keeps telemetry parameter for signature compatibility.
fuzzing/Opc.Ua.Encoders.Fuzz.Tests/Issue3546RoundTripTests.cs Removes NUnit setup that previously created/reassigned the message context.
fuzzing/Opc.Ua.Encoders.Fuzz.Tests/EncoderTests.cs Replaces per-test setup override with a regression test for context initialization.

Comment thread fuzzing/Opc.Ua.Encoders.Fuzz.Tests/EncoderTests.cs
@marcschier
marcschier marked this pull request as draft July 19, 2026 11:35
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 11:54
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as draft July 19, 2026 16:21
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 16:30
@marcschier
marcschier requested a review from romanett July 19, 2026 18:37
@marcschier marcschier added the ready Ready to merge once CI Passes label Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.56%. Comparing base (12f770b) to head (2821b12).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4035      +/-   ##
==========================================
- Coverage   73.86%   73.56%   -0.31%     
==========================================
  Files        1345     1345              
  Lines      180038   180081      +43     
  Branches    31678    31683       +5     
==========================================
- Hits       132993   132472     -521     
- Misses      36290    36897     +607     
+ Partials    10755    10712      -43     

see 46 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants