Skip to content

Fix NullReferenceException in Rabbit. #7083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

NachoEchevarria
Copy link
Contributor

@NachoEchevarria NachoEchevarria commented Jun 10, 2025

Summary of changes

We are getting the following NullReferenceException.

Error : Exception occurred when calling the CallTarget integration continuation.
System.NullReferenceException
at Datadog.Trace.ClrProfiler.AutoInstrumentation.RabbitMQ.PopulateBasicPropertiesHeadersIntegration.OnMethodEnd[TTarget,TReturn](TTarget instance, TReturn returnValue, Exception exception, CallTargetState& state)
at RabbitMQ.Client.Impl.Channel.PopulateBasicPropertiesHeaders[TProperties](TProperties basicProperties, Activity sendActivity, UInt64 publishSequenceNumber)

We can reproduce the issue with the following code:

BasicProperties property = default; -> NULL
var duckType = property.DuckCast<IBasicProperties>()!; -> duckType = NULL
duckType.Headers ??= new Dictionary<string, object>(); -> NullReferenceException

Reason for change

Implementation details

Test coverage

Other details

@NachoEchevarria NachoEchevarria changed the title Fix null reference exception in Rabbit. [LANGPLAT-402] Fix null reference exception in Rabbit. Jun 10, 2025
@NachoEchevarria NachoEchevarria changed the title Fix null reference exception in Rabbit. Fix NullReferenceException in Rabbit. Jun 10, 2025
Copy link
Member

@andrewlock andrewlock left a comment

Choose a reason for hiding this comment

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

Thanks!

@@ -80,6 +80,10 @@ internal static CallTargetState OnMethodBegin<TTarget, TBasicProperties, TActivi
basicProperties = CachedBasicPropertiesHelper<TReturn>.CreateHeaders(state.State!);
}
}
else
{
basicProperties = returnValue;
Copy link
Member

Choose a reason for hiding this comment

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

I think we could/should also change the definition of basicProperties above to this?

        TReturn basicProperties;

Alternatively, we could remove the else and change the definition to

        TReturn basicProperties = returnValue;

But I think the else is probably clearer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@andrewlock
Copy link
Member

andrewlock commented Jun 10, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (68ms)  : 65, 70
     .   : milestone, 68,
    master - mean (67ms)  : 65, 70
     .   : milestone, 67,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (1,009ms)  : 985, 1033
     .   : milestone, 1009,
    master - mean (1,004ms)  : 983, 1024
     .   : milestone, 1004,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (102ms)  : 100, 104
     .   : milestone, 102,
    master - mean (102ms)  : 100, 105
     .   : milestone, 102,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (697ms)  : 679, 715
     .   : milestone, 697,
    master - mean (696ms)  : 680, 713
     .   : milestone, 696,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (89ms)  : 86, 92
     .   : milestone, 89,
    master - mean (89ms)  : 87, 91
     .   : milestone, 89,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (658ms)  : 634, 682
     .   : milestone, 658,
    master - mean (660ms)  : 630, 690
     .   : milestone, 660,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.8) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (190ms)  : 186, 195
     .   : milestone, 190,
    master - mean (190ms)  : 186, 194
     .   : milestone, 190,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (1,113ms)  : 1089, 1137
     .   : milestone, 1113,
    master - mean (1,114ms)  : 1085, 1142
     .   : milestone, 1114,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (270ms)  : 266, 275
     .   : milestone, 270,
    master - mean (269ms)  : 266, 272
     .   : milestone, 269,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (886ms)  : 855, 916
     .   : milestone, 886,
    master - mean (884ms)  : 851, 917
     .   : milestone, 884,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (7083) - mean (263ms)  : 260, 266
     .   : milestone, 263,
    master - mean (261ms)  : 258, 265
     .   : milestone, 261,

    section CallTarget+Inlining+NGEN
    This PR (7083) - mean (876ms)  : 839, 912
     .   : milestone, 876,
    master - mean (873ms)  : 836, 911
     .   : milestone, 873,

Loading

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jun 10, 2025

Datadog Report

All test runs cf96970 🔗

2 Total Test Services: 0 Failed, 2 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Test Service View
dd-trace-dotnet 0 0 0 558030 4575 27h 0m 23.17s Link
exploration_tests 0 0 0 22085 3 2m 12s Link

@NachoEchevarria NachoEchevarria marked this pull request as ready for review June 10, 2025 14:14
@NachoEchevarria NachoEchevarria requested review from a team as code owners June 10, 2025 14:14
Copy link
Collaborator

@bouwkast bouwkast left a comment

Choose a reason for hiding this comment

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

Nice thanks!

@NachoEchevarria
Copy link
Contributor Author

Thanks!

@NachoEchevarria NachoEchevarria merged commit 69fa830 into master Jun 10, 2025
132 checks passed
@NachoEchevarria NachoEchevarria deleted the nacho/FixRabbirtNullReference branch June 10, 2025 15:53
@github-actions github-actions bot added this to the vNext-v3 milestone Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants