ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.22k stars 111 forks source link

The "IkvmCompiler" task failed unexpectedly. System.NullReferenceException. #281

Closed max-win-at closed 1 year ago

max-win-at commented 1 year ago

I have a project that compiles fine on my machine via latest msbuild 2022. However, as soon as my build server tries its luck I get the following exception message:

_CompileIkvmReferences:
user-path\.nuget\packages\ikvm\8.3.1\buildTransitive\netstandard2.0\IKVM.Tasks.targets(33,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly. 
user-path\.nuget\packages\ikvm\8.3.1\buildTransitive\netstandard2.0\IKVM.Tasks.targets(33,9): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
...

I am referencing a jar-file via <IkvmReference>. Targetframework is net48. Both machines have the same msbuild and dotnet sdk versions installed. Any ideas? Am I missing something?

wasabii commented 1 year ago

Well, I have to recommend you update to the latest IKVM version first, and check.

max-win-at commented 1 year ago

Did that. No joy. Maybe having a look at the full stack trace tells you more than me.


09:24:32,573 INFO  -                 Target _CompileIkvmReferences:
09:24:32,573 INFO  -                         Creating directory "obj\Debug\net48\ikvm\stage\1\eb21b46c0a7151c08011d797d04c80be".
09:24:32,573 INFO  -                         Creating directory "C:\Users\cl2auto\AppData\Local\Temp\ikvm\cache\1\eb21b46c0a7151c08011d797d04c80be".
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly.
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: System.NullReferenceException: Object reference not set to an instance of an object.
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at Microsoft.Build.CommandLine.OutOfProcTaskHostNode.ShouldTreatWarningAsError(String warningCode)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at Microsoft.Build.Utilities.TaskLoggingHelper.LogWarning(String subcategory, String warningCode, String helpKeyword, String helpLink, String file, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String message, Object[] messageArgs)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at Microsoft.Build.Utilities.TaskLoggingHelper.LogWarning(String message, Object[] messageArgs)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at IKVM.MSBuild.Tasks.IkvmToolTaskDiagnosticWriter.ReceiveAsync(IkvmToolDiagnosticEvent event) in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmToolTaskDiagnosticWriter.cs:line 56
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at IKVM.Tools.Runner.Compiler.IkvmCompilerLauncher.<ExecuteAsync>b__4_0(String i) in D:\a\ikvm\ikvm\src\IKVM.Tools.Runner\Compiler\IkvmCompilerLauncher.cs:line 293
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.PipeTarget.<>c__DisplayClass11_0.<<ToDelegate>b__0>d.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\PipeTarget.cs:line 176
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.PipeTarget.<>c__DisplayClass11_0.<<ToDelegate>b__0>d.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\PipeTarget.cs:line 175
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.AnonymousPipeTarget.<CopyFromAsync>d__2.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\PipeTarget.cs:line 34
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.Command.<PipeStandardErrorAsync>d__46.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\Command.cs:line 425
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.Command.<PipeStandardErrorAsync>d__46.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\Command.cs:line 425
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.Command.<AttachAsync>d__47.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\Command.cs:line 469
09:24:35,734 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at CliWrap.Command.<AttachAsync>d__47.MoveNext() in D:\a\CliWrap\CliWrap\CliWrap\Command.cs:line 486
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at IKVM.Tools.Runner.Compiler.IkvmCompilerLauncher.<ExecuteAsync>d__4.MoveNext() in D:\a\ikvm\ikvm\src\IKVM.Tools.Runner\Compiler\IkvmCompilerLauncher.cs:line 309
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at IKVM.MSBuild.Tasks.IkvmCompiler.<ExecuteAsync>d__212.MoveNext() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmCompiler.cs:line 273
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at IKVM.MSBuild.Tasks.IkvmToolExecTask.Execute() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmToolExecTask.cs:line 79
09:24:35,735 ERROR -                         C:\Users\cl2auto\.nuget\packages\ikvm\8.4.4\buildTransitive\netstandard2.0\IKVM.Tasks.targets(31,9): error MSB4018: at Microsoft.Build.CommandLine.OutOfProcTaskAppDomainWrapperBase.InstantiateAndExecuteTask(IBuildEngine oopTaskHostNode, LoadedType taskType, String taskName, String taskLocation, String taskFile, Int32 taskLine, Int32 taskColumn, AppDomainSetup appDomainSetup, IDictionary`2 taskParams)
shapeh commented 1 year ago

Having the same problem with Azure DevOps builds. Sometimes build fails, sometimes not. If it fails, we just restart the build and things are working fine again. Also running ikvm\8.4.4.

/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018: The "IkvmCompiler" task failed unexpectedly. [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path '/src/Infrastructure/OurProject.SomePath.Infrastructure/obj/Release/net7.0/linux-x64/ikvm/stage/1/b677e6d5a61a3768a4b8295db55e187f/jeval-net.dll.dll.rsp'. [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at System.IO.File.WriteToFile(String path, FileMode mode, String contents, Encoding encoding) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.Tools.Runner.Compiler.IkvmCompilerLauncher.ExecuteAsync(IkvmCompilerOptions options, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.Tools.Runner\Compiler\IkvmCompilerLauncher.cs:line 259 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmCompiler.ExecuteAsync(IkvmToolTaskDiagnosticWriter writer, CancellationToken cancellationToken) in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmCompiler.cs:line 273 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at IKVM.MSBuild.Tasks.IkvmToolExecTask.Execute() in D:\a\ikvm\ikvm\src\IKVM.MSBuild.Tasks\IkvmToolExecTask.cs:line 79 [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
/root/.nuget/packages/ikvm/8.4.4/buildTransitive/netstandard2.0/IKVM.Tasks.targets(31,9): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/src/Core/OurProject.SomePath.Services/OurProject.SomePath.Services.csproj]
wasabii commented 1 year ago

Well these seem like different problems. I'll see if I can reproduce it today. Works fine locally though?

shapeh commented 1 year ago

It works fine locally. And it works when we restart the build on Azure DevOps, so maybe something is not being done in the right order with DevOps in the first instance.

wasabii commented 1 year ago

Can you get it to fail when running it by hand in the same way you are on DevOps?

wasabii commented 1 year ago

Might be fixed by 6399fcb4

shapeh commented 1 year ago

Thank you. Will try with # 6399fcb - any chance you will merge this into the NuGet?

wasabii commented 1 year ago

Yeah seems worth a hotfix. I'll prepare a prerelease.

shapeh commented 1 year ago

Thank you for the good work! :)

wasabii commented 1 year ago

@shapeh Your issue seems to be a different issue. Not even the same error message. Opened as #282

wasabii commented 1 year ago

So this issue (281) seems to be that the ikvmc.exe process is returning stdout or stderr content after the MSBuild engine has died and the AppDomain has started shutting down. The MSBuild task attempts to log ikvmc output using MSBuildTaskLogHelper, back to the original AppDomain that holds the engine. But, the AppDomain could maybe survive the engine.

Fix is to catch exceptions that happen while logging and ignore them. If you can't log, there's not much we can log to indicate we can't log.

max-win-at commented 1 year ago

Just for the record. I can confirm that the issue is fixed in IKVM 8.4.5-prerelease0001. Thank you for the swift response.