How do I debug a mono project? I can't seem to run it. It builds perfectly. But running it is another issue altogether.
This is the output from running it.
$ mono SvnTest.exe update
Stacktrace:
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi (intptr) <0x00045>
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.PtrToStringAnsi (intptr) <0x00045>
at PumaCode.SvnDotNet.AprSharp.AprString.ToString () <0x0004b>
at PumaCode.SvnDotNet.SubversionSharp.SvnException.ExtractMessage (PumaCode.SvnDotNet.SubversionSharp.SvnError) <0x00033>
at PumaCode.SvnDotNet.SubversionSharp.SvnException..ctor (PumaCode.SvnDotNet.SubversionSharp.SvnError) <0x0001b>
at PumaCode.SvnDotNet.SubversionSharp.SvnClient.Update (PumaCode.SvnDotNet.SubversionSharp.SvnPath,PumaCode.SvnDotNet.SubversionSharp.SvnOptRevision,bool,PumaCode.SvnDotNet.SubversionSharp.SvnClientContext,PumaCode.SvnDotNet.AprSharp.AprPool) <0x000e3>
at PumaCode.SvnDotNet.SubversionSharp.SvnClient.Update (string,PumaCode.SvnDotNet.SubversionSharp.SvnRevision,bool) <0x0009f>
at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.UpdateCmd.Execute () <0x0015f>
at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.CmdBase.Run (PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.Application/SubCommand,string[]) <0x00551>
at (wrapper runtime-invoke) <Module>.runtime_invoke_int__this___object_object (object,intptr,intptr,intptr) <0x00060>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[],System.Exception&) <0x00057>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[],System.Exception&) <0x00057>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <0x001ab>
at System.Reflection.MethodBase.Invoke (object,object[]) <0x0002d>
at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.Application.Run (string[]) <0x0034b>
at PumaCode.SvnDotNet.SubversionSharp.SvnMockApp.Application.Main (string[]) <0x00037>
at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0x00054>
Native stacktrace:
mono() [0x48419c]
mono() [0x4ce1bf]
/lib/libpthread.so.0(+0xee80) [0x7f64b72b2e80]
/lib/libc.so.6(strlen+0x12) [0x7f64b6d477c2]
mono(mono_string_new+0x1d) [0x57f80d]
[0x4047e705]
Debug info from gdb:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Aborted
toString() method
public override string ToString()
{
if(IsNull)
return ("[apr_string:NULL]");
else
return (Marshal.PtrToStringAnsi(mString));
}
Clearly the mString member contains a garbage pointer. Judging from the call stack, you'll need help from the SubversionSharp team. Or find out somehow why it is trying to handle a Subversion error.
The last post at their web site dates from 2006, "We're not dead!". Their forum server looks pretty dead to me though. Good luck.
Related
By default in my xamarin forms app I have
AppCompatDelegate.DefaultNightMode =AppCompatDelegate.ModeNightNo;
But when I start it in dark mode I get the following exception
enter image description here,
in Xamarin.Forms.Platform.Android\PlatformConfigurationExtensions.cs
System.NullReferenceException:'Object reference not set to an instance of an object.'
Stacktrace:
at Xamarin.Forms.Platform.Android.PlatformConfigurationExtensions.OnThisPlatform[T] (T element) [0x00000]
in D:\a\1\s\Xamarin.Forms.Platform.Android\PlatformConfigurationExtensions.cs:8
at Xamarin.Forms.Platform.Android.AppCompat.FragmentContainer.OnResume () [0x00007]
in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\FragmentContainer.cs:126
at AndroidX.Fragment.App.Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00008]
in D:\a\1\s\generated\androidx.fragment.fragment\obj\Release\monoandroid9.0\generated\src\AndroidX.Fragment.App.Fragment.cs:2548
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.115(intptr,intptr)
It only happens in dark mode, in light mode it init normally.
I was trying to debug but all the threads at that moment are executing external code
After updating Android's Support Libraries (v28.0+) to get targeted with monoandroid90, the app crashes sometimes with the stack trace I provided bellow. If there are breakpoints active this won't happen.
Different versions of Xamarin.Android were tested, the current one I'm using is the latest 9.4 that comes with the default vs19. I was not able to reproduce this on a fresh install of the vs17 with the default XA that comes with it (9.1.7.0)
The following stack trace shows the current problem I'm facing.
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x00007>
at (wrapper runtime-invoke) <Module>.runtime_invoke_bool (object,intptr,intptr,intptr) [0x0002b] in <ff07eae8184a40a08e79049bbcb31a0e>:0
"Finalizer"08-06 16:26:25.748 E/mono (11487): Full thread dump:
"Thread Pool Worker" at <unknown> <0xffffffff>
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x00007>
at (wrapper runtime-invoke) <Module>.runtime_invoke_bool (object,intptr,intptr,intptr) [0x0002b] in <ff07eae8184a40a08e79049bbcb31a0e>:0
"Debugger agent"
"Timer-Scheduler" at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Threading.WaitHandle.Wait_internal (intptr*,int,bool,int) <0x00007>
at System.Threading.WaitHandle.WaitOneNative (System.Runtime.InteropServices.SafeHandle,uint,bool,bool) [0x0001f] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.WaitHandle.InternalWaitOne (System.Runtime.InteropServices.SafeHandle,long,bool,bool) [0x00019] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.WaitHandle.WaitOne (long,bool) [0x00010] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.WaitHandle.WaitOne (int,bool) [0x0001d] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.WaitHandle.WaitOne (int) [0x00003] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.Timer/Scheduler.SchedulerThread () [0x00043] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.ThreadHelper.ThreadStart_Context (object) [0x0001f] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00073] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00004] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) [0x0002f] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at System.Threading.ThreadHelper.ThreadStart () [0x00014] in <ff07eae8184a40a08e79049bbcb31a0e>:0
at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00067] in <ff07eae8184a40a08e79049bbcb31a0e>:0
"<unnamed thread>"
08-06 16:26:35.755 I/libc (11487): Requested dump for tid 11487 (ler.challengeme)
Anybody else has ever faced this issue and is aware of a possible solution?
I am trying to bind an external accessory MSR SDK to Xamarin. Note, this is ON the device. It does not work in the simulator at all. I keep getting this error:
Wrapper type 'iMagProII.IMag' is missing its native ObjectiveC class 'IMag'.
Here is my .cs with my linker flags:
[assembly: LinkWith ("libiMagSDK.a", LinkTarget = LinkTarget.ArmV6 | LinkTarget.ArmV7 | LinkTarget.Simulator, SmartLink = true, ForceLoad = true, IsCxx = true, Frameworks = "CoreGraphics ExternalAccessory", LinkerFlags="-lsqlite3.0 -lc++")]
Here is the Stack Trace:
at MonoTouch.Registrar.DynamicRegistrar.OnRegisterType (MonoTouch.Registrar.ObjCType type) [0x00334] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.DynamicRegistrar.cs:573
at MonoTouch.Registrar.Registrar.RegisterTypeUnsafe (System.Type type, System.Collections.Generic.List`1& exceptions) [0x009a4] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Registrar.cs:1027
at MonoTouch.Registrar.Registrar.RegisterType (System.Type type, System.Collections.Generic.List`1& exceptions) [0x00011] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Registrar.cs:680
at MonoTouch.Registrar.DynamicRegistrar.Register (System.Type type) [0x00002] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.DynamicRegistrar.cs:839
at MonoTouch.ObjCRuntime.Class.Register (System.Type type) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/.pmcs-compat.Class.cs:126
at MonoTouch.ObjCRuntime.Class.GetHandle (System.Type type) [0x00000] in <filename unknown>:0
at MonoTouch.Foundation.NSObject.AllocIfNeeded () [0x00015] in /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.NSObject2.cs:390
at MonoTouch.Foundation.NSObject..ctor (MonoTouch.Foundation.NSObjectFlag x) [0x00006] in /Developer/MonoTouch/Source/maccore/src/Foundation/.pmcs-compat.NSObject2.cs:102
at iMagProII.IMag..ctor () [0x00000] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII/obj/Debug/ios/iMagProII/IMag.g.cs:112
at iMagProII.iOS.ImagViewController.ViewDidLoad () [0x0005c] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/ImagViewController.cs:46
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
at MonoTouch.UIKit.UIViewController.get_View () [0x00030] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/.pmcs-compat.UIViewController.g.cs:2232
at iMagProII.iOS.ImagViewController..ctor () [0x00008] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/ImagViewController.cs:23
at iMagProII.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00016] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/AppDelegate.cs:33
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/.pmcs-compat.UIApplication.cs:38
at iMagProII.iOS.Application.Main (System.String[] args) [0x00008] in /Users//Projects/Xamarin/Bindings/Unimag/iMagProII.iOS/Main.cs:17
Any help on getting this library bound would be greatly appreciated. I have been banging my head at it for hours now.
This occurs when the class IMag can't be found in the final executable.
The most common reasons for this are:
A typo in the class name.
The native library does not include the architecture you're building for. For instance the native library needs to contain i386 code to run in the simulator. You can use the lipo tool to list the architectures in the native library:
$ lipo -info /path/to/libiMagSDK.a
You also need to know the architecture you're using for the app, you can check this in the project's iOS Build settings, on the Advanced page. Select one that the native library includes.
The native library in the binding project depends on another native library which is not in the binding project (and the IMag class is in that other library). All non-platform dependencies must be included.
The native library is incorrectly built, and doesn't include the class you're trying to bind (this is not frequent, but I've still seen it several times). You can use the nm tool to check what's included in a native library:
$ nm -arch armv7 /path/to/libiMagSDK.a | grep IMag
0x0000f00d S _OBJC_CLASS_$_IMag
[other results]
The above result would indicate that the class is included in the native library.
I'm getting a System.MissingMethodException when I try to instantiate a Dictionary using the Android.Gms.Maps.Model.Marker class as follows:
Dictionary<Marker, MyInnerClass> _markers = new Dictionary<Marker, MyInnerClass>();
I suspect that somehow a needed dll is not being loaded but don't know why. The problem seems to be specific to my specific dev environment since other developers with the same code are not seeing this problem. I can reproduce the issue in Genymotion, an Asus Tablet and a GS4 all running Android 4.2.2.
Application output reports the following:
[] Missing method Android.Runtime.JNIEnv::AllocObject(Type) in assembly Mono.Android.dll, referenced in assembly GooglePlayServices.dll
Here's the stack trace:
System.MissingMethodException: Method not found: 'Android.Runtime.JNIEnv.AllocObject'.
at MyProduct.Maps.MyMapFragment..ctor () [0x00013] in /Users/me/code/my.domain/MyProduct/Maps/MyMapFragment.cs:48
at at (wrapper dynamic-method) object.ffa689fb-fdde-4e08-abd8-3bdf6ae641fb (intptr,object[]) <IL 0x00018, 0x00037>
at Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/src/Java.Interop/TypeManager.cs:141
at at (wrapper native-to-managed) Java.Interop.TypeManager.n_Activate (intptr,intptr,intptr,intptr,intptr,intptr) <IL 0x00020, 0x0007f>
at at (wrapper managed-to-native) object.wrapper_native_0xb65e0e20 (intptr,intptr,intptr,intptr,Android.Runtime.JValue[]) <0x00003>
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00000] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:612
at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:3824
at MyProduct.MyListActivity.OnCreate (Android.OS.Bundle) [0x00079] in /Users/me/code/my.domain/MyProduct/MyListActivity.cs:83
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.2-branch/a25a31d0/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1937
at at (wrapper dynamic-method) object.24a01956-09ee-4dec-9155-eff468f7249c (intptr,intptr,intptr) <IL 0x00017, 0x0001f>
Android.Runtime.JNIEnv.AllocObject() is a method that was added to Xamarin.Android 4.10.1.
It would seem that GooglePlayServices.dll was built against 4.10, while your app was packaged against 4.8 (which doesn't contain AllocObject()). This would explain the MissingMethodException.
Xamarin.Android 4.10.1 is now stable; please upgrade.
I'll admit this is my homework. The task statement said I have to write a program that finds a topological order of a graph which would be inputted by standard input. Then I need to submit it to be graded on the professor's server.
Now it's not the algorithm problem. It's more of a technical problem. In my computer, I use .NET compiler (csc) while the professor's grading machine uses some form of mono.
It works well, until the grader said I got 30/100. A friend of mine suggested that I use the grader's "manual input system", so here I go, I made it create array-of-100000 lists for the adjacency list.
The grader, after a few seconds, reported that my program has crashed.
Stacktrace:
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke_object__this__ (object,intptr,intptr,intptr) <0xffffffff>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0x00004>
at (wrapper managed-to-native) object.__icall_wrapper_mono_object_new_fast (intptr) <0xffffffff>
at System.Exception.ToString () <0x00026>
at (wrapper runtime-invoke) object.runtime_invoke
This is kinda strange and unsettling to me, but I have yet to find an answer for this. Again, this program worked really fine on my PC.
This is my part of the program:
using System;
using System.Collections;
using System.Collections.Generic;
class topo{
public static void Main(){
string[] ST = Console.ReadLine().Split(' ');
int N=Convert.ToInt32(ST[0]), M=Convert.ToInt32(ST[1]);
int[] ins = new int[N]; //node's total in-degrees
List<int>[] E = new List<int>[N];
for(int n=0;n<N;n++)
E[n] = new List<int>();
for(int m=0;m<M;m++){
ST = Console.ReadLine().Split(' ');
int u = Convert.ToInt32(ST[0]);
int v = Convert.ToInt32(ST[1]);
E[u-1].Add(v-1);
ins[v-1]++;
}
Queue S = new Queue();
List<int> L = new List<int>(); //result list
for(int n=0;n<N;n++){
//add stranded nodes directly and don't process it
if(ins[n]==0 && E[n].Count==0)
L.Add(n);
//put into queue
else if(ins[n]==0)
S.Enqueue(n);
}
while(S.Count>0){
int n = (int) S.Dequeue();
L.Add(n);
foreach(int m in E[n])
if(--ins[m]==0)
S.Enqueue(m);
}
foreach(int n in L)
Console.WriteLine(n+1);
}
}
Thank you very much, and I appreciate any and every response.
Edit: I took another look at the grader's output to see if I missed anything, and indeed I did. It said "syscal: 2", but all I know about it is that "the program didn't exit normally."
Edit #2: I've tried making the program attempt to make various sizes of the array-of-list, ranging from 5000, 10000, etc. and after 40000 the "manual input system" said the program got a System.OutOfMemoryException. With further look into various parts of the grader that the students are allowed into, it seems that prof misconfigured his grading parameters and gave us less memory than announced. (He said "32MB", but the program crashes at about 16MB)
I've reported the error to him and he is (right now) looking into it.
The following code is going to fail if the value of u or v is less than 1.
for(int m=0;m<M;m++){
ST = Console.ReadLine().Split(' ');
int u = Convert.ToInt32(ST[0]);
int v = Convert.ToInt32(ST[1]);
E[u-1].Add(v-1);
ins[v-1]++;
}
Because u-1 or v-1 is going to be negative, and that will throw an exception.
Followup: This is anecdotal, self-answer, and very late because I just realized that it's okay to answer myself. I was later notified that I went over the memory limit enforced by the grading system. However, the exception was quite cryptic in my case and the grader did not report this issue. (It marked me only as incorrect.)
I was also quite careless to not realize that smaller inputs worked, and that's why I got 30/100 and not zero points.
For future readers: When programming in an automatic-grader environment, please make sure your program does not go over the memory limit, which may be there but may not be known to you (i.e. not written in problem statement).