Add proper error checking around GetModuleMetadata (#5985 => v2)#5992
Conversation
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing the following branches/commits: Execution-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 shown 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). gantt
title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (74ms) : 65, 83
. : milestone, 74,
master - mean (69ms) : 67, 71
. : milestone, 69,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (1,039ms) : 1017, 1061
. : milestone, 1039,
master - mean (1,077ms) : 1053, 1101
. : milestone, 1077,
gantt
title Execution time (ms) FakeDbCommand (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (109ms) : 105, 114
. : milestone, 109,
master - mean (109ms) : 105, 112
. : milestone, 109,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (727ms) : 704, 749
. : milestone, 727,
master - mean (758ms) : 739, 778
. : milestone, 758,
gantt
title Execution time (ms) FakeDbCommand (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (93ms) : 89, 96
. : milestone, 93,
master - mean (92ms) : 90, 95
. : milestone, 92,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (678ms) : 654, 703
. : milestone, 678,
master - mean (710ms) : 697, 724
. : milestone, 710,
gantt
title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (191ms) : 186, 195
. : milestone, 191,
master - mean (190ms) : 187, 192
. : milestone, 190,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (1,115ms) : 1096, 1135
. : milestone, 1115,
master - mean (1,160ms) : 1137, 1184
. : milestone, 1160,
gantt
title Execution time (ms) HttpMessageHandler (.NET Core 3.1)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (275ms) : 270, 279
. : milestone, 275,
master - mean (274ms) : 270, 279
. : milestone, 274,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (882ms) : 857, 907
. : milestone, 882,
master - mean (922ms) : 902, 942
. : milestone, 922,
gantt
title Execution time (ms) HttpMessageHandler (.NET 6)
dateFormat X
axisFormat %s
todayMarker off
section Baseline
This PR (5992) - mean (264ms) : 260, 268
. : milestone, 264,
master - mean (264ms) : 259, 268
. : milestone, 264,
section CallTarget+Inlining+NGEN
This PR (5992) - mean (865ms) : 845, 885
. : milestone, 865,
master - mean (902ms) : 883, 922
. : milestone, 902,
|
Benchmarks Report for appsec 🐌Benchmarks for #5992 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.Asm.AppSecBodyBenchmark - Slower
|
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.Asm.AppSecBodyBenchmark.ObjectExtractorMoreComplexBody‑netcoreapp3.1 | 1.176 | 3,955.87 | 4,651.39 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | AllCycleSimpleBody |
net6.0 | 72.4μs | 81.3ns | 304ns | 0.0723 | 0 | 0 | 6 KB |
| master | AllCycleSimpleBody |
netcoreapp3.1 | 62.9μs | 113ns | 438ns | 0.094 | 0 | 0 | 6.95 KB |
| master | AllCycleSimpleBody |
net472 | 49.6μs | 30.6ns | 115ns | 1.31 | 0 | 0 | 8.34 KB |
| master | AllCycleMoreComplexBody |
net6.0 | 78.5μs | 50.2ns | 188ns | 0.118 | 0 | 0 | 9.51 KB |
| master | AllCycleMoreComplexBody |
netcoreapp3.1 | 69μs | 86.1ns | 322ns | 0.138 | 0 | 0 | 10.37 KB |
| master | AllCycleMoreComplexBody |
net472 | 55.4μs | 41ns | 159ns | 1.88 | 0.0277 | 0 | 11.85 KB |
| master | ObjectExtractorSimpleBody |
net6.0 | 140ns | 0.125ns | 0.435ns | 0.00397 | 0 | 0 | 280 B |
| master | ObjectExtractorSimpleBody |
netcoreapp3.1 | 199ns | 0.131ns | 0.473ns | 0.00371 | 0 | 0 | 272 B |
| master | ObjectExtractorSimpleBody |
net472 | 171ns | 0.158ns | 0.59ns | 0.0446 | 0 | 0 | 281 B |
| master | ObjectExtractorMoreComplexBody |
net6.0 | 3.04μs | 3.38ns | 12.6ns | 0.0533 | 0 | 0 | 3.78 KB |
| master | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 3.96μs | 3.18ns | 11.9ns | 0.0494 | 0 | 0 | 3.69 KB |
| master | ObjectExtractorMoreComplexBody |
net472 | 3.81μs | 1.98ns | 7.67ns | 0.603 | 0.00572 | 0 | 3.8 KB |
| #5992 | AllCycleSimpleBody |
net6.0 | 73.4μs | 242ns | 937ns | 0.0719 | 0 | 0 | 6.01 KB |
| #5992 | AllCycleSimpleBody |
netcoreapp3.1 | 62.9μs | 57.5ns | 223ns | 0.0624 | 0 | 0 | 6.95 KB |
| #5992 | AllCycleSimpleBody |
net472 | 49.1μs | 39.5ns | 153ns | 1.32 | 0 | 0 | 8.34 KB |
| #5992 | AllCycleMoreComplexBody |
net6.0 | 78.5μs | 45ns | 162ns | 0.119 | 0 | 0 | 9.51 KB |
| #5992 | AllCycleMoreComplexBody |
netcoreapp3.1 | 68.9μs | 76.4ns | 286ns | 0.138 | 0 | 0 | 10.37 KB |
| #5992 | AllCycleMoreComplexBody |
net472 | 56.3μs | 60.1ns | 233ns | 1.87 | 0.028 | 0 | 11.85 KB |
| #5992 | ObjectExtractorSimpleBody |
net6.0 | 147ns | 0.661ns | 2.65ns | 0.00396 | 0 | 0 | 280 B |
| #5992 | ObjectExtractorSimpleBody |
netcoreapp3.1 | 207ns | 0.704ns | 2.73ns | 0.00375 | 0 | 0 | 272 B |
| #5992 | ObjectExtractorSimpleBody |
net472 | 165ns | 0.191ns | 0.738ns | 0.0446 | 0 | 0 | 281 B |
| #5992 | ObjectExtractorMoreComplexBody |
net6.0 | 3.08μs | 9.91ns | 38.4ns | 0.0533 | 0 | 0 | 3.78 KB |
| #5992 | ObjectExtractorMoreComplexBody |
netcoreapp3.1 | 4.65μs | 3.85ns | 14.9ns | 0.0493 | 0 | 0 | 3.69 KB |
| #5992 | ObjectExtractorMoreComplexBody |
net472 | 3.9μs | 3.09ns | 11.6ns | 0.602 | 0.00585 | 0 | 3.8 KB |
Benchmarks.Trace.Asm.AppSecEncoderBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | EncodeArgs |
net6.0 | 36.7μs | 17ns | 65.9ns | 0.446 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
netcoreapp3.1 | 54.1μs | 27ns | 101ns | 0.433 | 0 | 0 | 32.4 KB |
| master | EncodeArgs |
net472 | 66μs | 26.8ns | 104ns | 5.15 | 0.0661 | 0 | 32.5 KB |
| master | EncodeLegacyArgs |
net6.0 | 72.8μs | 106ns | 412ns | 0 | 0 | 0 | 2.14 KB |
| master | EncodeLegacyArgs |
netcoreapp3.1 | 106μs | 383ns | 1.48μs | 0 | 0 | 0 | 2.15 KB |
| master | EncodeLegacyArgs |
net472 | 151μs | 128ns | 495ns | 0.304 | 0 | 0 | 2.15 KB |
| #5992 | EncodeArgs |
net6.0 | 40.3μs | 64.9ns | 252ns | 0.459 | 0 | 0 | 32.4 KB |
| #5992 | EncodeArgs |
netcoreapp3.1 | 54.3μs | 55.7ns | 208ns | 0.432 | 0 | 0 | 32.4 KB |
| #5992 | EncodeArgs |
net472 | 67.6μs | 78.6ns | 294ns | 5.15 | 0.0673 | 0 | 32.5 KB |
| #5992 | EncodeLegacyArgs |
net6.0 | 76.3μs | 402ns | 2.13μs | 0.0393 | 0 | 0 | 2.14 KB |
| #5992 | EncodeLegacyArgs |
netcoreapp3.1 | 103μs | 117ns | 452ns | 0 | 0 | 0 | 2.14 KB |
| #5992 | EncodeLegacyArgs |
net472 | 152μs | 84.6ns | 317ns | 0.305 | 0 | 0 | 2.15 KB |
Benchmarks.Trace.Asm.AppSecWafBenchmark - Same speed ✔️ Same allocations ✔️
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunWafRealisticBenchmark |
net6.0 | 184μs | 63.1ns | 244ns | 0 | 0 | 0 | 2.42 KB |
| master | RunWafRealisticBenchmark |
netcoreapp3.1 | 194μs | 255ns | 986ns | 0 | 0 | 0 | 2.37 KB |
| master | RunWafRealisticBenchmark |
net472 | 209μs | 137ns | 532ns | 0.314 | 0 | 0 | 2.43 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net6.0 | 122μs | 74.3ns | 288ns | 0 | 0 | 0 | 1.46 KB |
| master | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 130μs | 193ns | 747ns | 0 | 0 | 0 | 1.45 KB |
| master | RunWafRealisticBenchmarkWithAttack |
net472 | 139μs | 209ns | 783ns | 0.208 | 0 | 0 | 1.48 KB |
| #5992 | RunWafRealisticBenchmark |
net6.0 | 184μs | 517ns | 2μs | 0 | 0 | 0 | 2.42 KB |
| #5992 | RunWafRealisticBenchmark |
netcoreapp3.1 | 193μs | 315ns | 1.22μs | 0 | 0 | 0 | 2.37 KB |
| #5992 | RunWafRealisticBenchmark |
net472 | 207μs | 57.4ns | 222ns | 0.309 | 0 | 0 | 2.43 KB |
| #5992 | RunWafRealisticBenchmarkWithAttack |
net6.0 | 122μs | 61.6ns | 238ns | 0 | 0 | 0 | 1.46 KB |
| #5992 | RunWafRealisticBenchmarkWithAttack |
netcoreapp3.1 | 129μs | 136ns | 510ns | 0 | 0 | 0 | 1.45 KB |
| #5992 | RunWafRealisticBenchmarkWithAttack |
net472 | 138μs | 45.7ns | 171ns | 0.208 | 0 | 0 | 1.48 KB |
Benchmarks.Trace.Iast.StringAspectsBenchmark - Same speed ✔️ More allocations ⚠️
More allocations ⚠️ in #5992
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472
278.53 KB
286.54 KB
8.01 KB
2.88%
Fewer allocations 🎉 in #5992
Benchmark
Base Allocated
Diff Allocated
Change
Change %
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1
255.52 KB
253.41 KB
-2.11 KB
-0.83%
Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472
62.13 KB
59.02 KB
-3.1 KB
-5.00%
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑net472 | 278.53 KB | 286.54 KB | 8.01 KB | 2.88% |
| Benchmark | Base Allocated | Diff Allocated | Change | Change % |
|---|---|---|---|---|
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatAspectBenchmark‑netcoreapp3.1 | 255.52 KB | 253.41 KB | -2.11 KB | -0.83% |
| Benchmarks.Trace.Iast.StringAspectsBenchmark.StringConcatBenchmark‑net472 | 62.13 KB | 59.02 KB | -3.1 KB | -5.00% |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | StringConcatBenchmark |
net6.0 | 60.8μs | 838ns | 8.29μs | 0 | 0 | 0 | 43.44 KB |
| master | StringConcatBenchmark |
netcoreapp3.1 | 53.1μs | 219ns | 930ns | 0 | 0 | 0 | 42.64 KB |
| master | StringConcatBenchmark |
net472 | 37.3μs | 96.2ns | 360ns | 0 | 0 | 0 | 62.13 KB |
| master | StringConcatAspectBenchmark |
net6.0 | 323μs | 1.83μs | 12.5μs | 0 | 0 | 0 | 255.88 KB |
| master | StringConcatAspectBenchmark |
netcoreapp3.1 | 345μs | 2μs | 16.5μs | 0 | 0 | 0 | 255.52 KB |
| master | StringConcatAspectBenchmark |
net472 | 266μs | 4.34μs | 42.3μs | 0 | 0 | 0 | 278.53 KB |
| #5992 | StringConcatBenchmark |
net6.0 | 57μs | 651ns | 6.45μs | 0 | 0 | 0 | 43.44 KB |
| #5992 | StringConcatBenchmark |
netcoreapp3.1 | 56.7μs | 600ns | 5.69μs | 0 | 0 | 0 | 42.64 KB |
| #5992 | StringConcatBenchmark |
net472 | 37.3μs | 178ns | 690ns | 0 | 0 | 0 | 59.02 KB |
| #5992 | StringConcatAspectBenchmark |
net6.0 | 311μs | 1.64μs | 12.2μs | 0 | 0 | 0 | 255.01 KB |
| #5992 | StringConcatAspectBenchmark |
netcoreapp3.1 | 299μs | 5.33μs | 52.5μs | 0 | 0 | 0 | 253.41 KB |
| #5992 | StringConcatAspectBenchmark |
net472 | 245μs | 1.21μs | 6.4μs | 0 | 0 | 0 | 286.54 KB |
Benchmarks Report for tracer 🐌Benchmarks for #5992 compared to master:
The following thresholds were used for comparing the benchmark speeds:
Allocation changes below 0.5% are ignored. Benchmark detailsBenchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️Raw results
Benchmarks.Trace.TraceAnnotationsBenchmark - Slower
|
| Benchmark | diff/base | Base Median (ns) | Diff Median (ns) | Modality |
|---|---|---|---|---|
| Benchmarks.Trace.TraceAnnotationsBenchmark.RunOnMethodBegin‑net6.0 | 1.141 | 601.97 | 686.65 |
Raw results
| Branch | Method | Toolchain | Mean | StdError | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|---|---|---|---|---|---|---|---|---|---|
| master | RunOnMethodBegin |
net6.0 | 602ns | 0.275ns | 1.07ns | 0.00972 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
netcoreapp3.1 | 898ns | 0.268ns | 1ns | 0.00945 | 0 | 0 | 696 B |
| master | RunOnMethodBegin |
net472 | 1.06μs | 0.522ns | 2.02ns | 0.104 | 0 | 0 | 658 B |
| #5992 | RunOnMethodBegin |
net6.0 | 687ns | 0.315ns | 1.18ns | 0.00968 | 0 | 0 | 696 B |
| #5992 | RunOnMethodBegin |
netcoreapp3.1 | 932ns | 0.505ns | 1.95ns | 0.00936 | 0 | 0 | 696 B |
| #5992 | RunOnMethodBegin |
net472 | 1.04μs | 0.517ns | 1.93ns | 0.104 | 0 | 0 | 658 B |
Summary of changes
Explicitly check for
S_OKwhen callingGetModuleMetadata.Reason for change
GetModuleMetadatacan returnS_FALSE(one known case is if the module is a resource, but there might be other). We've been using theSUCCEEDED/FAILEDmacros to check the error code, butS_FALSEis not considered as an error so we would mistakenly assume that the call succeeded.Implementation details
Note that I only updated the error checks. There are a couple of places where we call
GetModuleMetadatawithout checking the error code, I haven't touched those.For
GetModuleInterfacesin IAST, I also moved the call toReleaseto only do it if the call succeeded.