dotnet / corert

This repo contains CoreRT, an experimental .NET Core runtime optimized for AOT (ahead of time compilation) scenarios, with the accompanying compiler toolchain.
http://dot.net
MIT License
2.91k stars 508 forks source link

Make PEVerify output useful #5060

Closed jkotas closed 4 years ago

jkotas commented 6 years ago

From @ygoe on November 10, 2015 17:45

I'm generating or manipulating assemblies at the IL level with Mono Cecil. This can lead to all sorts of errors and I use PEVerify to find them. But when the full output of PEVerify is just "The method does not exist." (or whatever the text is in English) then it's not helpful at all. No token number, no affected type, no nothing. Where should I even start to look for the problem? What does the detected problem look like? Why is a method missing, who wants to have it? The program doesn't run properly and I can see where it produces wrong results, but I don't see anything strange in that area.

I could provide you a broken assembly for reference but I can't upload it here.

Copied from original issue: dotnet/coreclr#2005

jkotas commented 6 years ago

From @leppie on November 11, 2015 5:49

Can you dump the IL as a gist? (also doing a ildasm/ilasm cycle might give more info about the error)

jkotas commented 6 years ago

From @ygoe on November 14, 2015 11:55

You can download the assembly files here:

https://drive.google.com/file/d/0B8CN0ghdY1SdaGdrZXlESVE3Y2s/view?usp=sharing

I haven't made especially good experience with ildasm+ilasm, Most of the time something is missing that is not represented with IL so the result is incomplete and doesn't work.

atykhyy commented 6 years ago

Bump. I also use Cecil for complex assembly modification and PEVerify to check the output, and I agree about PEVerify diagnostic messages being a bit too much on the terse side. (OTOH I realize that there are only a handful of users such as me and @ygoe who need the detailed diagnostics. Perhaps when PEVerify is open-sourced, or ILVerify matures to be a complete replacement, such users can pitch in and do a PR.) One other example:

[token nnn] Type load failed.

This message at least shows the type token, but a type can fail to load for any number of reasons and there's no clue at all. I have to run try { Assembly.LoadFrom (...).ManifestModule.ResolveType (nnn) } catch (Exception e) { Console.WriteLine (e.Message) ; } to get details.

jkotas commented 6 years ago

@atykhyy The open source replacement for PEVerify is being developed in this repo: https://github.com/dotnet/corert/blob/master/src/ILVerify/README.md

You can give it a try (you have to build it from source for now). If there are things you would like to see improved in error messages, please open issues on it or even better submit PRs to make the improvements.

ygoe commented 4 years ago

@jkotas Could you please provide an updated link to the supposed replacement of this closed issue? The last link is now broken (dotnet GitHub repos seem to change regularly) and a quick web search doesn't bring up anything obvious.

Suchiman commented 4 years ago

@ygoe the readme now lives at https://github.com/dotnet/runtime/blob/master/src/coreclr/src/tools/ILVerify/README.md

jkotas commented 4 years ago

I am updating the README.md with instructions for how to install it as a global tool.