@@ -14,11 +14,6 @@ namespace BenchmarkDotNet.Disassemblers
14
14
// This Disassembler uses ClrMd v2x. Please keep it in sync with ClrMdV1Disassembler (if possible).
15
15
internal abstract class ClrMdV2Disassembler
16
16
{
17
- // Translating an address to a method can cause AV and a process crash (https://github.com/dotnet/BenchmarkDotNet/issues/2070).
18
- // It was partially fixed in https://github.com/dotnet/runtime/pull/79846,
19
- // fully fixed in https://github.com/dotnet/runtime/pull/90797.
20
- protected static readonly bool IsVulnerableToAvInDac = ! RuntimeInformation . IsWindows ( ) && Environment . Version < new Version ( 8 , 0 ) ;
21
-
22
17
internal DisassemblyResult AttachAndDisassemble ( Settings settings )
23
18
{
24
19
using ( var dataTarget = DataTarget . AttachToProcess (
@@ -247,11 +242,15 @@ protected static bool TryReadNativeCodeAddresses(ClrRuntime runtime, ClrMethod m
247
242
248
243
protected void TryTranslateAddressToName ( ulong address , bool isAddressPrecodeMD , State state , bool isIndirectCallOrJump , int depth , ClrMethod currentMethod )
249
244
{
250
- var runtime = state . Runtime ;
245
+ // 0 or -1 (ulong.MaxValue) addresses are invalid, and will crash the runtime in older runtimes. https://github.com/dotnet/runtime/pull/90794
246
+ if ( address == 0 || address == ulong . MaxValue )
247
+ return ;
251
248
252
249
if ( state . AddressToNameMapping . ContainsKey ( address ) )
253
250
return ;
254
251
252
+ var runtime = state . Runtime ;
253
+
255
254
var jitHelperFunctionName = runtime . GetJitHelperFunctionName ( address ) ;
256
255
if ( ! string . IsNullOrEmpty ( jitHelperFunctionName ) )
257
256
{
@@ -276,7 +275,7 @@ protected void TryTranslateAddressToName(ulong address, bool isAddressPrecodeMD,
276
275
277
276
if ( method is null )
278
277
{
279
- if ( isAddressPrecodeMD || ! IsVulnerableToAvInDac )
278
+ if ( isAddressPrecodeMD )
280
279
{
281
280
var methodDescriptor = runtime . GetMethodByHandle ( address ) ;
282
281
if ( ! ( methodDescriptor is null ) )
@@ -293,14 +292,11 @@ protected void TryTranslateAddressToName(ulong address, bool isAddressPrecodeMD,
293
292
}
294
293
}
295
294
296
- if ( ! IsVulnerableToAvInDac )
295
+ var methodTableName = runtime . DacLibrary . SOSDacInterface . GetMethodTableName ( address ) ;
296
+ if ( ! string . IsNullOrEmpty ( methodTableName ) )
297
297
{
298
- var methodTableName = runtime . DacLibrary . SOSDacInterface . GetMethodTableName ( address ) ;
299
- if ( ! string . IsNullOrEmpty ( methodTableName ) )
300
- {
301
- state . AddressToNameMapping . Add ( address , $ "MT_{ methodTableName } ") ;
302
- return ;
303
- }
298
+ state . AddressToNameMapping . Add ( address , $ "MT_{ methodTableName } ") ;
299
+ return ;
304
300
}
305
301
return ;
306
302
}
0 commit comments