Quantcast

Native library with Monotouch 5.0 (part 2)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Native library with Monotouch 5.0 (part 2)

Robert Sweitzer
My native library seems to be breaking the non-LLVM armv6 build….LLVM armv7 works fine. However we MUST be able to debug code on the device. I compiled my (fat) library with LLVM GCC 4.2 and Apple LLVM compiler 3.0. In both cases running the non-LLVM-nibless armv6 App on my iPad2 throws a NullReferenceException with DialogViewController..ctor at the top-of-stack:

mMyViewController = new MyViewController();

MyViewController is defined as follows:

public class MyViewController : MonoTouch.Dialog.DialogViewController
{
        public MyViewController () : base(null /* no…it's not this */)  
        {
                // ...
        }
}

Note that NONE of my native code has been called at that point in the App...except c++ statics. In addition the App runs fine if I remove all the P/Invoke calls to my native library. The native library runs fine when called from a native (XCode) App. Are there any known issues with the armv6…I'm doing a debug iOS5 build with no optimizations ?

xcode 4.2 4C199
mtouch 5.0.1.1319647906
Additional mtouch arguments:
-cxx -gcc_flags "-ObjC -deadstrip -L${ProjectDir}/../../MobileSynchronizer_XCode/User/build/Debug-iphonesimulator -L${ProjectDir}/../../Tools/Arch/lib/Universal -L${ProjectDir}/../../Tools/openssl-1.0.0b/build/Debug-iphonesimulator -L${ProjectDir}/../../Tools/Sqlite-3.7.6.1/build/Debug-iphonesimulator -framework SystemConfiguration -larc -lcrypto -licucore -lUser -lsqlite -lssl -lxml2.2.7.3 -force_load ${ProjectDir}/../../Tools/openssl-1.0.0b/build/Debug-iphonesimulator/libcrypto.a ${ProjectDir}/../../Tools/openssl-1.0.0b/build/Debug-iphonesimulator/libssl.a ${ProjectDir}/../../Tools/Sqlite-3.7.6.1/build/Debug-iphonesimulator/libsqlite.a"

RSweitzer
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Robert Sweitzer
Update: I just upgraded to mtouch 5.0.2.1320356251. Instead of a NullReferenceException the App now crashes at the same point in my code with:

Stacktrace:

  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) <0x0010f>
  at Moby.Application.Main (string[]) [0x00000] in /Users/robertsweitzer/Projects/Webforce/CommunicationServices/Synchronization/MobileSynchronizer_Monotouch/Moby/Main.cs:17
  at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        0   Moby                                0x00583834 mono_handle_native_sigsegv + 456
        1   Moby                                0x0055c480 mono_sigsegv_signal_handler + 428
        2   libsystem_c.dylib                   0x310f8539 _sigtramp + 48
        3   ???                                 0x000000b0 0x0 + 176
        4   Moby                                0x001b207c Moby_AppDelegate_FinishedLaunching_MonoTouch_UIKit_UIApplication_MonoTouch_Foundation_NSDictionary + 2032
        5   Moby                                0x004b490c wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
        6   Moby                                0x0055c0a4 mono_jit_runtime_invoke + 2892
        7   Moby                                0x0066f618 mono_runtime_invoke + 200
        8   Moby                                0x0072af98 monotouch_trampoline + 3140
        9   UIKit                               0x3080e7eb -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1186
        10  UIKit                               0x308083bd -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 396
        11  UIKit                               0x307d6921 -[UIApplication handleEvent:withNewEvent:] + 1016
        12  UIKit                               0x307d63bf -[UIApplication sendEvent:] + 54
        13  UIKit                               0x307d5d2d _UIApplicationHandleEvent + 5808
        14  GraphicsServices                    0x36087e13 PurpleEventCallback + 882
        15  CoreFoundation                      0x37547553 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
        16  CoreFoundation                      0x375474f5 __CFRunLoopDoSource1 + 140
        17  CoreFoundation                      0x37546343 __CFRunLoopRun + 1370
        18  CoreFoundation                      0x374c94dd CFRunLoopRunSpecific + 300
        19  CoreFoundation                      0x374c93a5 CFRunLoopRunInMode + 104
        20  UIKit                               0x30807457 -[UIApplication _run] + 550
        21  UIKit                               0x30804743 UIApplicationMain + 1090
        22  Moby                                0x00247cbc wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 240
        23  Moby                                0x001b1220 Moby_Application_Main_string__ + 152
        24  Moby                                0x004b490c wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
        25  Moby                                0x0055c0a4 mono_jit_runtime_invoke + 2892
        26  Moby                                0x0066f618 mono_runtime_invoke + 200
        27  Moby                                0x00672838 mono_runtime_exec_main + 836
        28  Moby                                0x00671804 mono_runtime_run_main + 968
        29  Moby                                0x00567010 mono_jit_exec + 244
        30  Moby                                0x00551ff8 main + 3952
        31  Moby                                0x001ada44 start + 40

=================================================================
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.
=================================================================
RSweitzer
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Robert Sweitzer
I solved this after wasting many hours removing thumb code (bug 707) from all of my native libs. The issue was solved with -nolinkaway. I am using -linksdkonly and never received a linked-away exception.
RSweitzer
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Sebastien Pouliot
Hello Robert,

Is your test case one of the attached files in #707 ? if not the I
would appreciate if you could send us your test case and I'll try to
dig up why your particular case occurs (it should not, unless
something swallow the exception).

It seems there's more than a single issue there since #707 also occurs
when _no_ linking is being done (so --nolinkaway is not the solution).

Thanks,
Sebastien

On Sun, Nov 6, 2011 at 12:48 AM, Robert Sweitzer <[hidden email]> wrote:

> I solved this after wasting many hours removing thumb code (bug 707) from all
> of my native libs. The issue was solved with -nolinkaway. I am using
> -linksdkonly and never received a linked-away exception.
>
>
> -----
> RSweitzer
> --
> View this message in context: http://monotouch.2284126.n4.nabble.com/Native-library-with-Monotouch-5-0-part-2-tp3992408p3995043.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Robert Sweitzer
Hi Sebastien,

Removing thumb code from my libs had no impact on the problem. It (#707) was just something I tried while looking for a solution. The code works with the original libs...and breaks if I remove --nolinkaway. Is it possible that the code throwing the linked-away exception was also removed ?

Regards,
Robert
RSweitzer
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Sebastien Pouliot
Hello Robert,

I'd say pretty unlikely - but there's something unlikely going on...
but that's a large set of events.

The only way to resolve the mystery is to analyze a test case that
demonstrate the issue.

Regards,
Sebastien

On Mon, Nov 7, 2011 at 7:41 AM, Robert Sweitzer <[hidden email]> wrote:

> Hi Sebastien,
>
> Removing thumb code from my libs had no impact on the problem. It (#707) was
> just something I tried while looking for a solution. The code works with the
> original libs...and breaks if I remove --nolinkaway. Is it possible that the
> code throwing the linked-away exception was also removed ?
>
> Regards,
> Robert
>
> -----
> RSweitzer
> --
> View this message in context: http://monotouch.2284126.n4.nabble.com/Native-library-with-Monotouch-5-0-part-2-tp3992408p3998501.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Emanuele Sabetta
I think I have the same problem, check my post on StackOverflow:

http://stackoverflow.com/questions/8055442/monotouch-error-when-compiling-for-the-device-but-not-on-simulator-mono-patch-i

I've tried many tricks, but I'm still unable to debug on the iPhone.
Only the release with the LLVM compiler seems to work for now.

2011/11/7 Sebastien Pouliot <[hidden email]>:

> Hello Robert,
>
> I'd say pretty unlikely - but there's something unlikely going on...
> but that's a large set of events.
>
> The only way to resolve the mystery is to analyze a test case that
> demonstrate the issue.
>
> Regards,
> Sebastien
>
> On Mon, Nov 7, 2011 at 7:41 AM, Robert Sweitzer <[hidden email]> wrote:
>> Hi Sebastien,
>>
>> Removing thumb code from my libs had no impact on the problem. It (#707) was
>> just something I tried while looking for a solution. The code works with the
>> original libs...and breaks if I remove --nolinkaway. Is it possible that the
>> code throwing the linked-away exception was also removed ?
>>
>> Regards,
>> Robert
>>
>> -----
>> RSweitzer
>> --
>> View this message in context: http://monotouch.2284126.n4.nabble.com/Native-library-with-Monotouch-5-0-part-2-tp3992408p3998501.html
>> Sent from the MonoTouch mailing list archive at Nabble.com.
>> _______________________________________________
>> MonoTouch mailing list
>> [hidden email]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
> _______________________________________________
> MonoTouch mailing list
> [hidden email]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[hidden email]
http://lists.ximian.com/mailman/listinfo/monotouch
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Native library with Monotouch 5.0 (part 2)

Robert Sweitzer
Looking to allay concerns that I encountered some mysterious armv6 issue:

I spent some time trying to reproduce this in a small test App…the only way I could break the App was by building the lib with thumb enabled so suspect I didn't do a full rebuild earlier. It crashes differently than my App was (and with different linker combinations) but I suspect both are related to #707.

Regards,
Robert

Here are the details: (but armv6/thumb is half-baked)

App: An Xib-less (probably not important) copy of the Montouch.Dialog Sample:
Lib: https://github.com/davepeck/iOS-libarchive (probably any lib) built with LLVM GCC 4.2/GCC_THUMB_SUPPORT=YES

Put the following at the bottom of your FinishedLaunching () method:
IntPtr handle = archive_read_new();

[DllImport("__Internal")]
private static extern IntPtr archive_read_new();
RSweitzer
Loading...