[Dynamic Instrumentation] DEBUG-4871 Added a managed guard in LogLocal and LogArg to detect null byrefs by dudikeleti · Pull Request #7986 · DataDog/dd-trace-dotnet

@dudikeleti

…ing Unsafe.IsNullRef(ref T) and skip capture instead of dereferencing.

This was referenced

Dec 20, 2025

GreenMatan

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