[Dynamic Instrumentation] Skip arg/local when byref-like check fails#8566
Conversation
When IsTypeByRefLike fails (e.g. metadata cannot be resolved), the rewriter previously fell through and emitted LogArg/LogLocal calls for the value. If the value happened to be byref-like, this can produce invalid IL or runtime failures. Instead, treat the failure conservatively: log the warning and skip instrumentation for that argument/local, the same way we already do when the type is confirmed byref-like. Co-authored-by: Cursor <[email protected]>
BenchmarksBenchmark execution time: 2026-05-06 11:11:58 Comparing candidate commit bc9eea7 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 27 metrics, 0 unstable metrics, 61 known flaky benchmarks, 26 flaky benchmarks without significant changes.
|
jpbempel
left a comment
There was a problem hiding this comment.
sounds legit, but I found it unfortunate to have forgot this continue.
Tests could not catch this? at least make sure we are not instrumenting this case
I’ve only seen this in the snapshot exploration test, never in our integration tests or in customer code. |
Summary of changes
DebuggerMethodRewriter::WriteCallsToLogArgOrLocal, whenIsTypeByRefLikereturns a failure HRESULT, skip instrumentation for that argument/local instead of falling through.Reason for change
IsTypeByRefLikefails (e.g. metadata cannot be resolved), the rewriter previously continued and emittedLogArg/LogLocalcalls for the value. If the value happened to be byref-like, this can produce invalid IL or runtime failures (InvalidProgramException, crashes when reading the byref).Implementation details
continue;in theFAILED(hr)branch with a comment explaining the conservative behavior. No other changes.Test coverage
Other details