[Dynamic Instrumentation] Add NullByRefArgAndLocal test by dudikeleti · Pull Request #7987 · DataDog/dd-trace-dotnet
This was referenced
Dec 20, 2025
dudikeleti
changed the title
Add NullByRefArgAndLocal test
[Dynamic Instrumentation] Add NullByRefArgAndLocal test
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…l and LogArg to detect null byrefs (#7986) ## 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
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