Skip to content

Add null check before calling Path.GetFullPath#76696

Merged
MichalStrehovsky merged 2 commits intodotnet:mainfrom
wscho77:bug_fix_add_null_check_in_ILCompiler
Oct 25, 2022
Merged

Add null check before calling Path.GetFullPath#76696
MichalStrehovsky merged 2 commits intodotnet:mainfrom
wscho77:bug_fix_add_null_check_in_ILCompiler

Conversation

@wscho77
Copy link
Contributor

@wscho77 wscho77 commented Oct 6, 2022

filePath can be null when AddModule() is called by InheritOpenModules().

System.ArgumentNullException is occured when crossgen2 run with "--out-near-input --single-file-compilation" options.
To fix this bugs, add null check code in AddModule()

root:/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.0> ./corerun ./crossgen2/crossgen2.dll --jitpath /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.0/libclrjit.so --targetarch arm64 -r:/usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.0/*.dll --out-near-input --single-file-compilation /home/owner/HelloConsole.dll 
Error: Value cannot be null. (Parameter 'path')
System.ArgumentNullException: Value cannot be null. (Parameter 'path')
   at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at System.ArgumentException.ThrowNullOrEmptyException(String argument, String paramName)
   at System.IO.Path.GetFullPath(String path)
   at ILCompiler.CompilerTypeSystemContext.AddModule(String filePath, String expectedSimpleName, Boolean useForBinding, ModuleData oldModuleData, Boolean throwOnFailureToLoad) in /runtime/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs:line 187
   at ILCompiler.CompilerTypeSystemContext.InheritOpenModules(CompilerTypeSystemContext oldTypeSystemContext) in /runtime/src/coreclr/tools/Common/Compiler/CompilerTypeSystemContext.cs:line 266
   at ILCompiler.ReadyToRunCompilerContext..ctor(TargetDetails details, SharedGenericsMode genericsMode, Boolean bubbleIncludesCorelib, CompilerTypeSystemContext oldTypeSystemContext) in /runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs:line 64
   at ILCompiler.Program.Run() in /runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 265
   at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass181_0.<.ctor>b__0(InvocationContext context) in /runtime/src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs:line 287

filePath can be null when AddModule() is called by InheritOpenModules().
@ghost ghost added community-contribution Indicates that the PR has been added by a community member area-crossgen2-coreclr labels Oct 6, 2022
@wscho77 wscho77 force-pushed the bug_fix_add_null_check_in_ILCompiler branch 3 times, most recently from 33dab95 to 5b38b6c Compare October 6, 2022 03:25
@wscho77 wscho77 force-pushed the bug_fix_add_null_check_in_ILCompiler branch from 5b38b6c to 9d920ed Compare October 6, 2022 03:28
Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@danmoseley
Copy link
Member

ready to merge @MichalStrehovsky ?

@MichalStrehovsky MichalStrehovsky merged commit 5108757 into dotnet:main Oct 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-crossgen2-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants