[Dynamic Instrumentation] DEBUG-4871 Added a managed guard in LogLocal and LogArg to detect null byrefs#7986
Merged
dudikeleti merged 1 commit intomasterfrom Jan 21, 2026
Merged
Conversation
…ing Unsafe.IsNullRef(ref T) and skip capture instead of dereferencing.
This was referenced Dec 20, 2025
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (7986) and master. ✅ No regressions detected - check the details below Full Metrics ComparisonFakeDbCommand
HttpMessageHandler
Comparison explanationExecution-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 highlighted in **red**. The following thresholds were used for comparing the execution times:
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). Duration chartsFakeDbCommand (.NET Framework 4.8)gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (69ms) : 67, 70
master - mean (69ms) : 67, 70
section Bailout
This PR (7986) - mean (72ms) : 71, 73
master - mean (72ms) : 71, 73
section CallTarget+Inlining+NGEN
This PR (7986) - mean (1,009ms) : 959, 1058
master - mean (1,008ms) : 959, 1058
FakeDbCommand (.NET Core 3.1)gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (106ms) : 103, 108
master - mean (106ms) : 103, 108
section Bailout
This PR (7986) - mean (107ms) : 105, 108
master - mean (107ms) : 106, 108
section CallTarget+Inlining+NGEN
This PR (7986) - mean (711ms) : 684, 737
master - mean (709ms) : 681, 738
FakeDbCommand (.NET 6)gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (94ms) : 91, 96
master - mean (94ms) : 92, 95
section Bailout
This PR (7986) - mean (94ms) : 93, 95
master - mean (94ms) : 93, 95
section CallTarget+Inlining+NGEN
This PR (7986) - mean (667ms) : 643, 691
master - mean (663ms) : 644, 683
FakeDbCommand (.NET 8)gantt
title Execution time (ms) FakeDbCommand (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (92ms) : 90, 95
master - mean (92ms) : 90, 94
section Bailout
This PR (7986) - mean (93ms) : 91, 95
master - mean (93ms) : 92, 94
section CallTarget+Inlining+NGEN
This PR (7986) - mean (632ms) : 613, 650
master - mean (634ms) : 619, 648
HttpMessageHandler (.NET Framework 4.8)gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (193ms) : 189, 198
master - mean (193ms) : 189, 197
section Bailout
This PR (7986) - mean (197ms) : 194, 199
master - mean (196ms) : 194, 199
section CallTarget+Inlining+NGEN
This PR (7986) - mean (1,114ms) : 1055, 1174
master - mean (1,119ms) : 1052, 1186
HttpMessageHandler (.NET Core 3.1)gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (277ms) : 272, 282
master - mean (276ms) : 270, 282
section Bailout
This PR (7986) - mean (277ms) : 273, 281
master - mean (276ms) : 273, 280
section CallTarget+Inlining+NGEN
This PR (7986) - mean (911ms) : 860, 962
master - mean (904ms) : 856, 952
HttpMessageHandler (.NET 6)gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (270ms) : 266, 275
master - mean (270ms) : 265, 275
section Bailout
This PR (7986) - mean (269ms) : 266, 273
master - mean (269ms) : 266, 272
section CallTarget+Inlining+NGEN
This PR (7986) - mean (888ms) : 848, 928
master - mean (885ms) : 847, 923
HttpMessageHandler (.NET 8)gantt
title Execution time (ms) HttpMessageHandler (.NET 8)
dateFormat x
axisFormat %Q
todayMarker off
section Baseline
This PR (7986) - mean (269ms) : 264, 274
master - mean (268ms) : 264, 273
section Bailout
This PR (7986) - mean (269ms) : 266, 273
master - mean (269ms) : 266, 272
section CallTarget+Inlining+NGEN
This PR (7986) - mean (822ms) : 798, 846
master - mean (820ms) : 801, 839
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GreenMatan
approved these changes
Jan 11, 2026
tracer/src/Datadog.Trace/Debugger/Instrumentation/AsyncLineDebuggerInvoker.cs
Show resolved
Hide resolved
dudikeleti
added a commit
that referenced
this pull request
Jan 21, 2026
## Reason for change In some cases, we cannot rely on the method metadata to determine whether method arguments and locals exist, as they may still be skipped. ## Implementation details Track open nodes and open/close them as required. ## Test coverage #7987 ## Other details This PR is part of an effort to make the Snapshot Exploration Test run successfully end-to-end. #7986 #7989
dudikeleti
added a commit
that referenced
this pull request
Jan 21, 2026
…7989) ## Summary of changes Add defensive checks for open nodes before closing them, and delay writing `noCaptureReason` until we are certain that the array node is closed. ## Test coverage #7987 ## Other details This PR is part of an effort to make the Snapshot Exploration Test run successfully end-to-end. Related PRs: #7986 #7988
dudikeleti
added a commit
that referenced
this pull request
Jan 21, 2026
## Summary of changes Add a new test that uncovers two bugs: 1. When a null address is passed into our instrumentation code. 2. When locals or arguments exist but are skipped, resulting in an invalid JSON structure. ## Implementation details When a null address is passed to our debugger invoker classes, it must be handled explicitly by checking `Unsafe.IsNullRef`. ## Other details The test is currently skipped and will be enabled once the following PRs are merged: #7986 #7988 #7989
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.
Reason for change
Some methods can legitimately produce null managed byrefs (e.g., MemoryMarshal.GetReference(emptySpan)), which makes ref T point to address 0. Attempting to capture such locals/args would dereference an invalid reference and could crash in LogLocal/LogArg (NullReferenceException). This change makes DI runs stable and keeps probes installed while avoiding unsafe dereferences
Implementation details
Before reading a ref T capture input, we check Unsafe.IsNullRef(ref value) and return early to avoid dereferencing an invalid reference.
Current behavior is to skip capturing that member entirely (no misleading null value for non-nullable types like byte).
Follow-up option: if we decide we want the snapshot to explicitly show this case, we can reuse the existing snapshot notCapturedReason mechanism (no new reason added in this PR).
Test coverage
#7987
Other details
This PR is part of an effort to make the Snapshot Exploration Test run successfully end-to-end.
#7988
#7989