-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redo IL Verification #90418
Redo IL Verification #90418
Conversation
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr, @marek-safar Issue Details
|
Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas Issue Details
|
39e8430
to
e52903d
Compare
Tagging subscribers to 'linkable-framework': @eerhardt, @vitek-karas, @LakshanF, @sbomer, @joperezr, @marek-safar Issue Details
|
e52903d
to
2fb5f82
Compare
Locally I can reproduce the test failures on I believe this PR is ready to go @marek-safar @vitek-karas |
The failures are real now - I checked out this branch and rebased to main and it fails locally with:
|
Note that without rebase to main everything passes - so it has to be some interaction with very recent changes. |
Thanks for checking on that. I did not think to recheck the errors after the rebase. I will take a look |
2fb5f82
to
d2f1edb
Compare
@vitek-karas |
@vitek-karas I'm not sure what to make of CI. Are the failures related to my changes? |
The non-wasm failures were already fixed by #90699 - I don't know why rerunning doesn't bet that. We would have to restart the whole CI probably - not worth it. The wasm failures are definitely unrelated - they occur in other PRs as well. |
@vitek-karas Great. This PR is ready to go then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good - it's a lot of new code... but if it works and effectively enabled IL Verification everywhere (or almost), that's a big win.
@sbomer, could you please also take a quick look?
The one thing we could improve (eventually) is to avoid having to implement the TypeSystem->String conversions - we have that in the ILC type system.
...link/test/Mono.Linker.Tests.Cases.Expectations/Assertions/DisableIlVerifyDiffingAttribute.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/SkipIlVerifyAttribute.cs
Outdated
Show resolved
Hide resolved
...ools/illink/test/Mono.Linker.Tests.Cases.Expectations/Assertions/ExpectIlFailureAttribute.cs
Outdated
Show resolved
Hide resolved
|
||
public static class Extensions | ||
{ | ||
public static string GetMethodSignature (this MethodDefinitionHandle handler, MetadataReader metadataReader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this - eventually we might migrate this to use the internal type system from the ILCompiler (it's in the same repo, so taking a project reference is very cheap) which has full implementation of this. But that's for some other time.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ILVerification/ILChecker.cs
Outdated
Show resolved
Hide resolved
if (!DisableILDiffing (linkResult, original)) { | ||
var inputResults = inputVerifier.VerifyByName (file.FileNameWithoutExtension); | ||
|
||
outputResults = Diff (outputResults, inputResults); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice idea and I like it. My only hesitation is perf - if it makes tests a lot slower that would be something to think about... Did you try to get at least some rough understanding how much it costs to run the verifying twice effectively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a high level check of the performance impact. Running the same command CI does to run tests I got
Before
Time Elapsed 00:06:15
And with this PR
Time Elapsed 00:06:31
So it's essentially insignificant.
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ILVerification/ILChecker.cs
Outdated
Show resolved
Hide resolved
src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs
Show resolved
Hide resolved
d2f1edb
to
07ccd69
Compare
* Now checks all assemblies in the output directory rather than just `test.exe` * Once again respects the the ability to skip verifying a single assembly via `[SkipIlVerify("foo.dll")]` * Now loads core libraries from the output directory (if they exist) instead of from the runtime install dir. * ALC logic was removed. I do not understand what value this provided. * The class libraries lead to a lot of errors. Rather than having to filter out a large number of errors, I added diff'ing. ILVerify will check the input assembly and remove any errors that existed in the input assembly. This makes verifying class libraries viable. Without it, you'd have to use `[SkipIlverify]` on every core link test or filter out a lot of `VerifierError` values. * Moved IL verification back to `InitialChecking` where `PeVerifier` was * Add a test to verify that il verification is mostly working. It doesn't give complete coverage over every behavior, but it's better than nothing. * `SkipPeVerify` renamed to `SkipIlVerify` * `SkipPeVerifyForToolchian` was removed. There is only 1 tool now. * Removed `PeVerifier`. * Remove many [SkipIlVerify] attributes. Diffing means they are no longer needed * `ValidateTypeRefsHaveValidAssemblyRefs` now runs regardless of whether or not the IL is verified. It wasn't clear to me why this logic would only be useful when il was verified. * Change `UninitializedLocals` to use `ExpectIlFailure`. This test seems to expect invalid il. Might as well assert that rather than skip ilverify entirely. * Remove the logic that disables ilverify when a test uses the unsafe argument. Diffing makes this obsolete. * IL Verification errors have been greatly improved. ** will now output all IL errors in the failure message rather than just the first invalid IL. ** Type and Method names are now displayed in the error message. I didn't do an exhaustive implementation, SRM is so tedious to use, but it's better than not having it ** Tokens and Offsets are formatted nicely * Extension points opened up for Unity. ** We need to supply different search directories. ** We need to search for `.winmd` files since we support windows runtime. ** In general I opened some things up in case we need to call them
07ccd69
to
9a0bae5
Compare
return true; | ||
} | ||
|
||
protected string[] PossibleAssemblyExtensions => new[] { ".dll", ".exe", ".winmd" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added .winmd
here as well.
The test failures are either known or unrelated. |
Now checks all assemblies in the output directory rather than just
test.exe
Once again respects the the ability to skip verifying a single assembly via
[SkipIlVerify("foo.dll")]
Now loads core libraries from the output directory (if they exist) instead of from the runtime install dir.
ALC logic was removed. I do not understand what value this provided.
The class libraries lead to a lot of errors. Rather than having to filter out a large number of errors, I added diff'ing. ILVerify will check the input assembly and remove any errors that existed in the input assembly. This makes verifying class libraries viable. Without it, you'd have to use
[SkipIlverify]
on every core link test or filter out a lot ofVerifierError
values.Moved IL verification back to
InitialChecking
wherePeVerifier
wasAdd a test to verify that il verification is mostly working. It doesn't give complete coverage over every behavior, but it's better than nothing.
SkipPeVerify
renamed toSkipIlVerify
SkipPeVerifyForToolchian
was removed. There is only 1 tool now.Removed
PeVerifier
.Remove many [SkipIlVerify] attributes. Diffing means they are no longer needed
ValidateTypeRefsHaveValidAssemblyRefs
now runs regardless of whether or not the IL is verified. It wasn't clear to me why this logic would only be useful when il was verified.Change
UninitializedLocals
to useExpectIlFailure
. This test seems to expect invalid il. Might as well assert that rather than skip ilverify entirely.Remove the logic that disables ilverify when a test uses the unsafe argument. Diffing makes this obsolete.
Cut down on the number of
VerifierError
values that are filtered out. Diffing removes the need to filter them out.IL Verification errors have been greatly improved.
will now output all IL errors in the failure message rather than just the first invalid IL.
Type and Method names are now displayed in the error message. I didn't do an exhaustive implementation, SRM is so tedious to use, but it's better than not having it
Tokens and Offsets are formatted nicely
Extension points opened up for Unity.
We need to supply different search directories.
We need to search for
.winmd
files since we support windows runtime.In general I opened some things up in case we need to call them