-
Notifications
You must be signed in to change notification settings - Fork 150
[Dynamic Instrumentation] DEBUG-4871 Added a managed guard in LogLocal and LogArg to detect null byrefs #7986
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
base: master
Are you sure you want to change the base?
Conversation
…ing Unsafe.IsNullRef(ref T) and skip capture instead of dereferencing.
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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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