-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
ILVerify falsely reports a field being modified #102997
Comments
Tagging subscribers to this area: @JulieLeeMSFT |
The message could be better (it matches peverify.exe per dotnet/corert#4911 though), but the gist is that ILVerify checks whether the input is verifiable and ldsflda with an initonly field is documented as not verifiable in the ECMA-335 spec. We track adding a weaker mode to ILVerify that checks for valid IL in #37391. Roslyn generates ldsflda because the OpCode struct is marked readonly and therefore this doesn't violate C# type safety rules. But the code is unverifiable and ILVerify will warn. |
So basically, the |
ILVerify implements .NET Framework 4.0 set of verification rules. These rules were not officially amended for the new constructs such as |
Are those rules unofficially described anywhere besides compiler source code? |
The theoretical verification rules are sometimes discussed in the C# design notes: https://github.com/search?q=repo%3Adotnet%2Fcsharplang%20verification . I do not see the discussion for this specific case. I think the rules for this specific case would be:
|
Resolving as duplicate of #57444 |
Description
ILVerify is usually pretty good at finding invalid IL in your code. But I've stumbled across something that's either a false positive or a bug in Roslyn's C# codgen, and I'm guessing it's the former, because the error message does not match what's in either the C# code or the decompiled CIL. (If this is actually a Roslyn problem, let me know and I'll refile this bug on the Roslyn repo.)
Reproduction Steps
Build the following, then examine the resulting DLL in ILVerify
Expected behavior
As the flagship .NET language, it's expected that the official C# compiler does not produce invalid IL.
It is also expected that official IL verification tools do not report invalid IL where none exists.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
.NET 9, most recent daily build as of 6/3/2024
Windows 10, x64
Other information
No response
The text was updated successfully, but these errors were encountered: