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

Cannot compile/run HelloWorld app on OS X #4203

Closed
gonzalocasas opened this issue May 1, 2015 · 13 comments
Closed

Cannot compile/run HelloWorld app on OS X #4203

gonzalocasas opened this issue May 1, 2015 · 13 comments

Comments

@gonzalocasas
Copy link

@gonzalocasas gonzalocasas commented May 1, 2015

Just did a clean install on OS X 10.10.3 following instructions here and when I try to run it, I get a type initialization exception on the SHA1 crypto service provider from Roslyn about sequence with no elements.

Am I missing something obvious?

Here's the output from dnvm list:

$ dnvm list

Active Version              Runtime Arch Location             Alias
------ -------              ------- ---- --------             -----
  *    1.0.0-beta5-11672    coreclr x64  ~/.dnx/runtimes
       1.0.0-beta4          mono         ~/.dnx/runtimes
       1.0.0-beta5-11672    mono         ~/.dnx/runtimes      default

And here's the exception I get when I run dnx . run:

System.IO.FileLoadException: Resource string id=0x1A88
File name: 'net-core-test, Culture=neutral, PublicKeyToken=null' ---> System.TypeInitializationException: The type initializer for 'Roslyn.Utilities.SHA1CryptoServiceProvider' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Roslyn.Utilities.HashAlgorithm' threw an exception. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Roslyn.Utilities.HashAlgorithm..cctor()
   --- End of inner exception stack trace ---
   at Roslyn.Utilities.HashAlgorithm.LoadAlgorithmCreate(String name)
   at Roslyn.Utilities.SHA1CryptoServiceProvider..cctor()
   --- End of inner exception stack trace ---
   at Roslyn.Utilities.SHA1CryptoServiceProvider..ctor()
   at Microsoft.CodeAnalysis.CryptographicHashProvider.TryGetAlgorithm(SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.CalculateChecksum(Stream stream, SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.From(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, Boolean throwIfBinaryDetected)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.<>c__DisplayClass14_0.<CreateSyntaxTree>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CreateSyntaxTree(String sourcePath, CSharpParseOptions parseOptions)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.GetSyntaxTrees(ICompilationProject project, IEnumerable`1 sourceFiles, IEnumerable`1 sourceReferences, CSharpParseOptions parseOptions, Boolean isMainAspect)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CompileProject(ICompilationProject project, ILibraryKey target, IEnumerable`1 incomingReferences, IEnumerable`1 incomingSourceReferences, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.Roslyn.RoslynProjectCompiler.CompileProject(ICompilationProject project, ILibraryKey target, Func`1 referenceResolver, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.<GetLibraryExport>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.<>c__DisplayClass2_0.<GetLibraryExport>b__0(ILibraryExportProvider r)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.LibraryManager.GetLibraryExport(String name, String aspect)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name, IAssemblyLoadContext loadContext)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name)
   at dnx.host.LoaderContainer.Load(String name)
   at dnx.host.DefaultLoadContext.LoadAssembly(String name)
   at Microsoft.Framework.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(String name, Func`2 factory)
   at Microsoft.Framework.Runtime.Loader.LoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.Framework.Runtime.DefaultHost.GetEntryPoint(String applicationName)
   at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at dnx.host.Bootstrapper.RunAsync(List`1 args)
   at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
   at dnx.host.RuntimeBootstrapper.Execute(String[] args)
System.TypeInitializationException: The type initializer for 'Roslyn.Utilities.SHA1CryptoServiceProvider' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Roslyn.Utilities.HashAlgorithm' threw an exception. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Roslyn.Utilities.HashAlgorithm..cctor()
   --- End of inner exception stack trace ---
   at Roslyn.Utilities.HashAlgorithm.LoadAlgorithmCreate(String name)
   at Roslyn.Utilities.SHA1CryptoServiceProvider..cctor()
   --- End of inner exception stack trace ---
   at Roslyn.Utilities.SHA1CryptoServiceProvider..ctor()
   at Microsoft.CodeAnalysis.CryptographicHashProvider.TryGetAlgorithm(SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.CalculateChecksum(Stream stream, SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.From(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, Boolean throwIfBinaryDetected)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.<>c__DisplayClass14_0.<CreateSyntaxTree>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CreateSyntaxTree(String sourcePath, CSharpParseOptions parseOptions)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.GetSyntaxTrees(ICompilationProject project, IEnumerable`1 sourceFiles, IEnumerable`1 sourceReferences, CSharpParseOptions parseOptions, Boolean isMainAspect)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CompileProject(ICompilationProject project, ILibraryKey target, IEnumerable`1 incomingReferences, IEnumerable`1 incomingSourceReferences, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.Roslyn.RoslynProjectCompiler.CompileProject(ICompilationProject project, ILibraryKey target, Func`1 referenceResolver, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.<GetLibraryExport>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.<>c__DisplayClass2_0.<GetLibraryExport>b__0(ILibraryExportProvider r)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.LibraryManager.GetLibraryExport(String name, String aspect)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name, IAssemblyLoadContext loadContext)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name)
   at dnx.host.LoaderContainer.Load(String name)
   at dnx.host.DefaultLoadContext.LoadAssembly(String name)
   at Microsoft.Framework.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(String name, Func`2 factory)
   at Microsoft.Framework.Runtime.Loader.LoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
System.TypeInitializationException: The type initializer for 'Roslyn.Utilities.HashAlgorithm' threw an exception. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Roslyn.Utilities.HashAlgorithm..cctor()
   --- End of inner exception stack trace ---
   at Roslyn.Utilities.HashAlgorithm.LoadAlgorithmCreate(String name)
   at Roslyn.Utilities.SHA1CryptoServiceProvider..cctor()
System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at Roslyn.Utilities.HashAlgorithm..cctor()
@trpalmer
Copy link

@trpalmer trpalmer commented May 1, 2015

Same error on Linux (Ubuntu). Runs under the 11672 mono runtime fine, just not on coreclr.

@ellismg
Copy link

@ellismg ellismg commented May 1, 2015

@trpalmer Can you try installing libssl-dev. This provides the correctly named libcrypto.so file we need to do the SHA1 hashing.

@gonzalocasas I have not seen this before, but I will try to reproduce your issue locally. As a quick question, do you have XCode or the Command Line Developer tools installed? If so, what version?

@gonzalocasas
Copy link
Author

@gonzalocasas gonzalocasas commented May 1, 2015

@ellismg yes, I've XCode 6.3.1 (6D1002) installed, and also cli dev tools, I'd love to help fix this if possible

@trpalmer
Copy link

@trpalmer trpalmer commented May 1, 2015

@ellismg libssl-dev already installed:

dpkg -s libssl-dev
Package: libssl-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 6170
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: openssl
Version: 1.0.1f-1ubuntu2.11
Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2.11), zlib1g-dev
@hashanp
Copy link

@hashanp hashanp commented May 1, 2015

Same error on Mac OS X 10.10.3, under 1.0.0-beta5-11674. But when I ran it under mono it worked fine.

@richlander
Copy link
Member

@richlander richlander commented May 1, 2015

@ellismg I have a repro. I hit this same issue on 11674.

@kangaroo
Copy link

@kangaroo kangaroo commented May 1, 2015

Roslyn is doing:

               // https://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.transformblock(v=vs.110).aspx
                s_TransformBlock_Method = (from m in type.GetTypeInfo().GetDeclaredMethods("TransformBlock")
                                          let ps = m.GetParameters()
                                          where ps.Length == 5 && ps[0].ParameterType == typeof(byte[]) &&
                                                                  ps[1].ParameterType == typeof(int) &&
                                                                  ps[2].ParameterType == typeof(int) &&
                                                                  ps[3].ParameterType == typeof(byte[]) &&
                                                                  ps[4].ParameterType == typeof(int)
                                          select m).Single();

                // https://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.transformblock(v=vs.110).aspx
                s_TransformFinalBlock_Method = (from m in type.GetTypeInfo().GetDeclaredMethods("TransformFinalBlock")
                                          let ps = m.GetParameters()
                                          where ps.Length == 3 && ps[0].ParameterType == typeof(byte[]) &&
                                                                  ps[1].ParameterType == typeof(int) &&
                                                                  ps[2].ParameterType == typeof(int)
                                          select m).Single();

In its static .cctor.

The current System.Security.Cryptography.Hashing.dll that is being restored does not expose TransformBlock or TransformFinalBlock, which appears to be the cause of this.

This issue should probably be moved to corefx to fix the assembly, and duplicated into Roslyn to make their .cctor more robust.

@kangaroo
Copy link

@kangaroo kangaroo commented May 1, 2015

Specifically its probably this commit:

dotnet/roslyn@f87ef57#diff-638a53759ec71cb81b6f2287d85ec08b

@richlander
Copy link
Member

@richlander richlander commented May 7, 2015

This is fixed. Please install the latest CoreCLR DNX. If you see it again, re-open the issue.

@richlander richlander closed this May 7, 2015
@gonzalocasas
Copy link
Author

@gonzalocasas gonzalocasas commented May 7, 2015

It's alive! Thanks guys!
Is amazing to see this (open sourced cross-platform .net) happening!

@rkeithhill
Copy link

@rkeithhill rkeithhill commented May 14, 2015

How exactly is this fixed? I'm running 11760 coreclr x64 on Ubuntu 14.04.2 x64 and I get a stack trace that whines about libcrypto type initializer throwing an exception. Does the fix still require you to separately install libssl-dev? If so, would be nice to have that step added to the install instructions for Linux.

@ellismg
Copy link

@ellismg ellismg commented May 14, 2015

Yes, you still need libssl-dev. I will make sure it gets added back to the instructions.

@rkeithhill
Copy link

@rkeithhill rkeithhill commented May 14, 2015

Thanks!

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.