stack overflow in F# compiler running under mono - f#

I'm updating the tooling for my project llvm-fs, so I installed the new version of mono and tried to compile it. Using either mono 3.10.0 with fsharpc 3.1 under OS X or mono 3.2.8 with fsharpc 3.0 under ubuntu the compile fails with a stack overflow:
Unhandled Exception:
System.StackOverflowException: The requested operation caused a stack overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.StackOverflowException: The requested operation caused a stack overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_object_isinst (object,intptr)
at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
at Microsoft.FSharp.Compiler.Driver+DelayedDisposables.System-IDisposable-Dispose () [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter, Microsoft.FSharp.Compiler.ErrorLoggerProvider errorLoggerProvider) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.Driver.mainCompile (System.String[] argv, Boolean bannerAlreadyPrinted, Exiter exiter) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.runMain (System.String[] argv) [0x00000] in <filename unknown>:0
at Microsoft.FSharp.Compiler.CommandLineMain.main (System.String[] argv) [0x00000] in <filename unknown>:0
You can reproduce this error on linux or OS X by doing the following:
git clone git#github.com:fsprojects/llvm-fs.git
cd llvm-fs/
FSC=fsharpc ./build.bash
Under windows fsc 12.0.30815.0 the compile completes with no errors:
fsc --nologo --debug --sig:LLVMFSharp.fsi --target:library --out:LLVMFSharp.dll src/LLVM/FFIUtil.fs src/LLVM/Generated.fs src/LLVM/Core.fs src/LLVM/BitReader.fs src/LLVM/ExecutionEngine.fs src/LLVM/Extra.fs src/LLVM/Target.fs src/LLVM/Quote.fs
Is this a known issue and is there any way to work around it? I've tried passing different options to the mono runtime and none resulted in the compiler exiting normally. I do remember in the past mono has had some problems respecting tailcall instructions but I thought that those problems were mostly resolved. Thanks!

This is too long for a comment, but the error is triggered by this bit of code from generated.fs (in that commenting it out stops the stack overflow - there is an error later once this is commented out) (from line 6496-6506):
[<DllImport(
llvmAssemblyName,
EntryPoint="LLVMRunFunction",
CallingConvention=CallingConvention.Cdecl,
CharSet=CharSet.Ansi)>]
extern void* (* LLVMGenericValueRef *) runFunctionNative(
void* (* LLVMExecutionEngineRef *) EE,
void* (* LLVMValueRef *) F,
uint32 NumArgs,
void* (* LLVMGenericValueRef* *) Args)
// I don't know how to generate an "F# friendly" version of LLVMRunFunction
The crash is occuring in the code that outputs the signature file.
Disabling the signature file fixes the problem (but there is still an underlying bug somewhere).

Related

Xamarin UI Tests Error: Type 'MonoDevelop.MonoDroid.DeploymentException' is not marked as serializable

I'm currently getting the following error and stacktrace when attempting to run UI Tests locally against my Xamarin.Android project. This error doesn't occur on every run, but its pretty frequent. A clean and rebuild will usually "fix" it, but when trying to run all tests is the suite this is a really annoying error.
I'm not really sure where to proceed from here. Any direction on where to look for debugging this error, or if anyone know what causes the error, would be greatly appreciated.
System/Framework info:
NUnit: 2.6.4
Xamarin.UITests Version: 2.2.4
Android Target Framwork: 8.0
Visual Studio Professional 2017 for Mac Version 7.5 (build 1254)
Mono 5.10.1.47 (2017-12/8eb8f7d5e74) (64-bit)
Xamarin.Android: Version: 8.3.0.19 (Visual Studio Professional)
SetUp : System.Runtime.Serialization.SerializationException : Type 'MonoDevelop.MonoDroid.DeploymentException' in Assembly 'MonoDevelop.MonoDroid, Version=4.0.0.24, Culture=neutral, PublicKeyToken=3ead7498f347467b' is not marked as serializable.
Server stack trace:
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize (System.Object obj, System.Runtime.Serialization.ISurrogateSelector surrogateSelector, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, System.Runtime.Serialization.IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) [0x00175] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectinfo.cs:171
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize (System.Object obj, System.Runtime.Serialization.ISurrogateSelector surrogateSelector, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, System.Runtime.Serialization.IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) [0x00006] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectinfo.cs:110
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write (System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo objectInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo memberNameInfo, System.Runtime.Serialization.Formatters.Binary.NameInfo typeNameInfo) [0x00101] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectwriter.cs:422
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize (System.Object graph, System.Runtime.Remoting.Messaging.Header[] inHeaders, System.Runtime.Serialization.Formatters.Binary.__BinaryWriter serWriter, System.Boolean fCheck) [0x001d3] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryobjectwriter.cs:190
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers, System.Boolean fCheck) [0x0006e] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:233
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:211
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/serialization/formatters/binary/binaryformatter.cs:203
at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage (System.Runtime.Remoting.Channels.IServerChannelSinkStack sinkStack, System.Runtime.Remoting.Messaging.IMessage requestMsg, System.Runtime.Remoting.Channels.ITransportHeaders requestHeaders, System.IO.Stream requestStream, System.Runtime.Remoting.Messaging.IMessage& responseMsg, System.Runtime.Remoting.Channels.ITransportHeaders& responseHeaders, System.IO.Stream& responseStream) [0x00125] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs:182
Exception rethrown at [0]:
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
at (wrapper remoting-invoke) Xamarin.UITest.Utils.Integration.IIdeHost.PrepareTestApp(string)
at Xamarin.UITest.Utils.Integration.IdeConnection.PrepareTestApp () [0x00037] in <1bd397951f434cd4913ddc08b7bc45af>:0
at Xamarin.UITest.Utils.Integration.IdeIntegrationClient.TryConnect (Xamarin.UITest.Platform platform) [0x00064] in <1bd397951f434cd4913ddc08b7bc45af>:0
at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration, Xamarin.UITest.Shared.Execution.IExecutor executor) [0x000ad] in <1bd397951f434cd4913ddc08b7bc45af>:0
at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration) [0x00000] in <1bd397951f434cd4913ddc08b7bc45af>:0
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <1bd397951f434cd4913ddc08b7bc45af>:0
at Dalevia.UITests.AppInitializer.StartApp (Xamarin.UITest.Platform platform, Xamarin.UITest.Configuration.AppDataMode dataMode) [0x00010] in /Users/dfrisk/Source/Compass/Compass-Patient/src/src/Mobile/RedArrow.Compass.Patients.Mobile.UI.Tests/AppInitializer.cs:28
at Dalevia.UITests.AppInitializer.StartApp (Xamarin.UITest.Platform platform) [0x00001] in /Users/dfrisk/Source/Compass/Compass-Patient/src/src/Mobile/RedArrow.Compass.Patients.Mobile.UI.Tests/AppInitializer.cs:14
at Dalevia.UITests.BaseTests.BeforeEachTest () [0x00001] in /Users/dfrisk/Source/Compass/Compass-Patient/src/src/Mobile/RedArrow.Compass.Patients.Mobile.UI.Tests/Tests/BaseTests.cs:42
at Dalevia.UITests.Tests.CaseStatusTests.BeforeEachTest () [0x00001] in /Users/dfrisk/Source/Compass/Compass-Patient/src/src/Mobile/RedArrow.Compass.Patients.Mobile.UI.Tests/Tests/CaseStatusTests.cs:26
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
I also ran into this, and what worked for me was uninstalling the app on the device, then reinstalling with a fresh copy. Notably, I was connecting to a device that hadn't been used in a while, so it was several versions older than my current application.
Adding x86 as a supported ABI fixed this problem for me

Xamarin ios can't find default-568#2x

I can't even compile the default project from visual studio. I created a new project from the new project menu in a fresh directory, changed the app identifier to my apple developer app name, and compile, and it tells me that Default-568#2x.png does not exist.
here is the full error:
System.IO.FileNotFoundException: /Users/boemanation/Library/Caches/Xamarin/mtbs/builds/OpenGL_Xamarin_TestiOS/ddf7db6bef3b320db45c7f9f5fb4bd29/obj/iPhone/Debug/optimized/Default-568h#2x.png does not exist
File name: '/Users/boemanation/Library/Caches/Xamarin/mtbs/builds/OpenGL_Xamarin_TestiOS/ddf7db6bef3b320db45c7f9f5fb4bd29/obj/iPhone/Debug/optimized/Default-568h#2x.png'
at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) <0x34bb690 + 0x002ff> in <filename unknown>:0
at Xamarin.MacDev.Tasks.SmartCopyTaskBase.CopyFile (System.String source, System.String target, System.String targetItemSpec) <0x34bb578 + 0x000c7> in <filename unknown>:0
at Xamarin.MacDev.Tasks.SmartCopyTaskBase.Execute () <0x34bad88 + 0x00227> in <filename unknown>:0 OpenGL_Xamarin_Test.iOS
I am completely stumped. any ideas?
project > properties > disable "Optimize PNG images files for iOS"
This is a workaround to solve this issue.

Xamarin forms ios Crash on start

On my iOS project, my app crash to start in debug , but in release it works.
Xamarin Forms : 1.3
Xamarin Forms Labs 1.2.1 Pre 2
My error :
Exception has been thrown by the target of an invocation.
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x000af] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:329
at System.Activator.CreateInstance (System.Type type) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:222
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00000] in <filename unknown>:0
Attempting to JIT compile method 'Microsoft.Scripting.Interpreter.LightLambda:MakeRun1<InviteVite.Entities.Event, System.DateTime> (Microsoft.Scripting.Interpreter.LightLambda)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at Microsoft.Scripting.Interpreter.LightLambda.MakeDelegate (System.Type delegateType) [0x0000d] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.47/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs:177
at Microsoft.Scripting.Interpreter.LightDelegateCreator.CreateDelegate (System.Runtime.CompilerServices.StrongBox`1[] closure) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.47/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs:109
at Microsoft.Scripting.Interpreter.CreateDelegateInstruction.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00043] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.47/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs:47
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0001b] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.47/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs:126
Thanks for your help
Have you tried enabling generic value type sharing?
Go to the iOS project's options, iOS Build section. On the Advanced tab check: "Enable generic value type sharing".

NullReferenceException when use Office 365 API in Xamarin.IOS

First I got this issue:
Using Office 365 API in Xamarin.Android
Now testing the same in Xamarin IOS I got another :(
{System.NullReferenceException: Object reference not set to an instance of an object
at Microsoft.Office365.OAuth.Authenticator.GetRefreshToken (System.String resource) [0x00000] in <filename unknown>:0
at Microsoft.Office365.OAuth.Authenticator+<GetAuthenticationResult>d__c.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Office365.OAuth.AuthenticationInfo].GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter_T.cs:59
at Microsoft.Office365.OAuth.Authenticator+<AuthenticateAsync>d__6.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:62
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.Office365.OAuth.AuthenticationInfo].GetResult () [0x00034] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/TaskAwaiter_T.cs:59
at Office365InXamarinApps.ViewModel.ContactsViewModel+<EnsureClientCreated>d__9.MoveNext () [0x00046] in c:\DevApps\GitHub\Office365InXamarinApps\scr\Office365InXamarinApps\Office365InXamarinApps\ViewModel\ContactsViewModel.cs:76 }
The code is here: https://github.com/saramgsilva/Office365InXamarinApp
The Office 365 API Preview has issues and I cannot use it, for this reason I created another demo using Office 365 REST API.
https://github.com/saramgsilva/Office365RESTAPISample
You may want to check out this blog post (see link in Xamarin Forum) -Xamarin developer was able to get it working in Android
http://forums.xamarin.com/discussion/21367/put-some-office-365-in-your-apps

Can not debug app in ios device with xamarin studio

I have developed an ipad app in xamarin studio(monotouch), suddenly I cannot debug this app in ios device(ipad) any more, but in ios simulator everything works fine.
From the "Build Output" I got following information, any ideas would be nice.
error MT0000: Unexpected error - Please file a bug report at http://bugzilla.xamarin.com
System.IO.IOException: Sharing violation on path /Volumes/BOOTCAMP/IPAD_GIT/Vendor12_IPad/bin/iPhone/Debug/Vendor12_IPad.app/MonoTouch.Dialog.PickerElement.dll.mdb
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean isAsync, Boolean anonymous) [0x00000] in :0
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess)
at Mono.CompilerServices.SymbolWriter.MonoSymbolWriter.WriteSymbolFile (Guid guid) [0x00000] in :0
at Mono.Cecil.Mdb.MdbWriter.Dispose () [0x00000] in :0
at Mono.Cecil.ReflectionWriter.TerminateModuleDefinition (Mono.Cecil.ModuleDefinition module) [0x00000] in :0
at Mono.Cecil.StructureWriter.TerminateAssemblyDefinition (Mono.Cecil.AssemblyDefinition asm) [0x00000] in :0
at Mono.Cecil.AssemblyDefinition.Accept (IReflectionStructureVisitor visitor) [0x00000] in :0
at Mono.Cecil.AssemblyFactory.WriteAssembly (Mono.Cecil.AssemblyDefinition asm, System.IO.BinaryWriter bw) [0x00000] in :0
at Mono.Cecil.AssemblyFactory.SaveAssembly (Mono.Cecil.AssemblyDefinition asm, System.IO.Stream stream) [0x00000] in :0
at Mono.Cecil.AssemblyFactory.SaveAssembly (Mono.Cecil.AssemblyDefinition asm, System.String file) [0x00000] in :0
at MTouch.SaveAssembly (Mono.Cecil.AssemblyDefinition assembly, Boolean symbols, System.String destination) [0x00000] in :0
at MTouch.Main2 (System.String[] args) [0x00000] in :0
at MTouch.Main (System.String[] args) [0x00000] in :0
This is probably caused by some oddity in your mounted file system in /Volumes/BOOTCAMP
Try moving your code out of it.
In the "iOS Build"->"Linker Options"->"Linker behavior" I set the value from "Link SDK assemblies only" to "Link all assemblies", and problem solved. But I still didn't understand the difference and don't know if there will be other problems by changing this setting.

Resources