Skip to content
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

System.NullReferenceException in ILRepack/ReferenceFixator.cs:line 520 #382

Open
schittli opened this issue Dec 21, 2024 · 1 comment
Open

Comments

@schittli
Copy link

schittli commented Dec 21, 2024

Hello

Thank you very much for sharing your great work for Microsoft with us for free,
while Microsoft makes 6.3 billion in net profit every month because we pay such massively inflated license fees. It's a pure shame that M$ is not offering professional, basic tools to their SW.

I received the following exception at ILRepack/ReferenceFixator.cs:line 520

System.NullReferenceException: Object reference not set to an instance of an object.
   at ILRepacking.ReferenceFixator.Fix(MethodReference method) in /_/ILRepack/ReferenceFixator.cs:line 520
   at ILRepacking.ReferenceFixator.FixReferences(Instruction instr) in /_/ILRepack/ReferenceFixator.cs:line 379
   at ILRepacking.ReferenceFixator.FixReferences(MethodBody body) in /_/ILRepack/ReferenceFixator.cs:line 351
   at ILRepacking.ReferenceFixator.FixReferences(MethodDefinition meth) in /_/ILRepack/ReferenceFixator.cs:line 292
   at ILRepacking.ReferenceFixator.FixReferences(TypeDefinition type) in /_/ILRepack/ReferenceFixator.cs:line 163
   at ILRepacking.Steps.ReferencesFixStep.Perform() in /_/ILRepack/Steps/ReferencesFixStep.cs:line 57
   at ILRepacking.ILRepack.RepackCore(String tempOutputDirectory) in /_/ILRepack/ILRepack.cs:line 433
   at ILRepacking.ILRepack.Repack() in /_/ILRepack/ILRepack.cs:line 295
   at ILRepacking.Application.Main(String[] args) in /_/ILRepack/Application.cs:line 49

The cause was

  • The Microsoft .net build tools somehow did not delete old DLLs
  • and Microsoft .net build did not recompile the corresponding modified source code
  • Therefore, ILRepack had DLL files that didn't match

To solve the problem:

  • I deleted .\src\bin\Debug\net8.0\ and rebuilt the solution,
  • » ILRepack perfectly worked.

Could you please think about:

  • Make the null check at ILRepack/ReferenceFixator.cs:line 520
  • and if there is a null, could you please display a hint that it might help if the user deletes the build output and restarts the build

Below is the verbose log, but unfortunately, I can not provide my source code.

Thanks a lot, kind regards,
Thomas

c:\Users\tom\.nuget\packages\ilrepack\2.0.36\tools\ILRepack.exe /ndebug /out:jig.ch.TomLib-Merged.dll 'jig.ch.CloudMirror.dll' 'jig.ch.TomLib.dll' /verbose
IL Repack - Version 2.0.36
Runtime: ILRepack, Version=2.0.36.0, Culture=neutral, PublicKeyToken=c3e9373f1c31208e
------------- IL Repack Arguments -------------
/ndebug /out:jig.ch.TomLib-Merged.dll jig.ch.CloudMirror.dll jig.ch.TomLib.dll /verbose
-----------------------------------------------
Adding assembly for merge: jig.ch.CloudMirror.dll
Resolved 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' from 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.11\System.Runtime.dll'
Resolved 'System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' from 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.11\System.Private.CoreLib.dll'
Adding assembly for merge: jig.ch.TomLib.dll
Processing references
Processing types
- Importing <Module> from jig.ch.CloudMirror.dll
- Importing <Module>
Merging <Module>
- Importing jig.ch.CloudMirror from jig.ch.CloudMirror.dll
- Importing jig.ch.CloudMirror
...
- Importing <Module> from jig.ch.TomLib.dll
- Importing <Module>
Merging <Module>
- Importing jig.ch.TomLib from jig.ch.TomLib.dll
- Importing jig.ch.TomLib
...
Processing exported types
Processing resources
Fixing references
- Fixing references for type <Module>
- Fixing references for type jig.ch.CloudMirror
- Fixing references for type jig.ch.Person
- Fixing references for type jig.ch.PersonExtensions
- Fixing references for type jig.ch.FileInfoExtensions
- Fixing references for type jig.ch.FileNameBuilder

System.NullReferenceException: Object reference not set to an instance of an object.
   at ILRepacking.ReferenceFixator.Fix(MethodReference method) in /_/ILRepack/ReferenceFixator.cs:line 520
   at ILRepacking.ReferenceFixator.FixReferences(Instruction instr) in /_/ILRepack/ReferenceFixator.cs:line 379
   at ILRepacking.ReferenceFixator.FixReferences(MethodBody body) in /_/ILRepack/ReferenceFixator.cs:line 351
   at ILRepacking.ReferenceFixator.FixReferences(MethodDefinition meth) in /_/ILRepack/ReferenceFixator.cs:line 292
   at ILRepacking.ReferenceFixator.FixReferences(TypeDefinition type) in /_/ILRepack/ReferenceFixator.cs:line 163
   at ILRepacking.Steps.ReferencesFixStep.Perform() in /_/ILRepack/Steps/ReferencesFixStep.cs:line 57
   at ILRepacking.ILRepack.RepackCore(String tempOutputDirectory) in /_/ILRepack/ILRepack.cs:line 433
   at ILRepacking.ILRepack.Repack() in /_/ILRepack/ILRepack.cs:line 295
   at ILRepacking.Application.Main(String[] args) in /_/ILRepack/Application.cs:line 49
@KirillOsenkov
Copy link
Collaborator

First let me just say that I absolutely share the sentiment that large corporations don't give back nearly enough to open source projects they depend on. I do whatever I can to alleviate that, however little that may be. I'm also very angry at Microsoft specifically, for a variety of reasons.

Regarding this bug, I can check for null, however this will fix the symptom, not the problem. To fix this properly I'd need to have the two assemblies being merged that resulted in the exception you're seeing, so I can debug and fix the problem at the root.

I'm guessing the assemblies are proprietary. If you still have the bad assemblies, you can email them to my first name dot last name at microsoft dot com, I can investigate and then delete the assemblies. However I understand that you can't reproduce the problem at will, it only happened with mismatched binaries, and even if you send me the new binaries I won't be able to reproduce.

For now there's not much I can do. I don't think a defensive fix would be of much help here, because it will still fail downstream, and I'd rather have the exception close to the source than "something went wrong" later.

If you ever see this again, you can either copy those two binaries and send them to me, or, if you can't share them, run this under the debugger and investigate yourself, and see why the Fix() method is returning null in the first place.

Thanks for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants