Bug 42664 - Could not AOT the assembly (on .EXE file)
Summary: Could not AOT the assembly (on .EXE file)
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: XI 9.6 (iOS 9.3)
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2016-07-19 15:45 UTC by rocco.dato
Modified: 2016-07-20 09:29 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Build output with AOT error on EliotAppStopNGoiOS.exe (688.63 KB, application/x-7z-compressed)
2016-07-19 15:45 UTC, rocco.dato
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description rocco.dato 2016-07-19 15:45:13 UTC
Created attachment 16719 [details]
Build output with AOT error on EliotAppStopNGoiOS.exe

Dear support,
I'm developing a commercial cross-platform app (android and iOS) but I'm facing an error when trying to build the iOS solution (with mtouch option set to "link SDK only")
The build process fails with:

Could not AOT the assembly '/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/64/Build/EliotAppStopNGoiOS.exe'

I can't attach the source code because of its commercial purpose, but I built the solution with MTOUCH arguments "-v -v -v -v" and stored part of the full output (the first part is missing, but there is something interesting at line 874083). This output is generated building on a MacPro from Visual Studio (via Mac Agent), but the problem appears also if I directly work on the Mac Pro machine.

How can I solve this problem? These are my system information:

=== Xamarin Studio Business ===
Version 6.0.2 (build 41)
Runtime:
	Mono 4.4.1 (mono-4.4.0-branch-c7sr0/4747417) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)
	Package version: 404010000
=== Apple Developer Tools ===
Xcode 7.3.1 (10188.1)
Build 7D1014
=== Xamarin.Mac ===
Version: 2.8.2.10 (Xamarin Business)
=== Xamarin.iOS ===
Version: 9.8.2.10 (Xamarin Business)
=== Build Information ===
Mac OS X 10.11.5


Thank you
Comment 1 Zoltan Varga 2016-07-19 19:08:37 UTC
The error seems to be this:

23>  AOT Compilation exited with code 134, command: (ID attività:761)
23>  MONO_PATH=/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/64/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.2.10/bin/arm64-darwin-mono-sgen --debug --llvm -O=gsharedvt  --aot=mtriple=arm64-ios,data-outfile=/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/EliotAppStopNGoiOS.arm64.aotdata,static,asmonly,direct-icalls,full,nodebug,dwarfdebug,llvm-path=/Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.2.10/LLVM/bin/,outfile=/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/EliotAppStopNGoiOS.exe.arm64.s,llvm-outfile=/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/EliotAppStopNGoiOS.exe.arm64-llvm.o "/Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/64/Build/EliotAppStopNGoiOS.exe" (ID attività:761)
23>  Mono Ahead of Time compiler - compiling assembly /Users/EmanueleDiEmanuele/Library/Caches/Xamarin/mtbs/builds/EliotAppStopNGoiOS/5901df1dbb00e5e420b8af380d31cee4/obj/iPhone/Release/mtouch-cache/64/Build/EliotAppStopNGoiOS.exe (ID attività:761)
23>  * Assertion at ../../../../../mono/mono/metadata/metadata.c:3643, condition `ptr' not met (ID attività:761)
Comment 2 Zoltan Varga 2016-07-19 19:10:36 UTC
Are there any obfuscators etc. ran on the EliotAppStopNGoiOS.exe assembly ?
Comment 3 rocco.dato 2016-07-20 09:29:01 UTC
We don't know exactly what the reason was, but we solved the problem by removing the following code which was actually unused in our app:

[DllImport (MonoTouch.Constants.SystemLibrary)]
    static internal extern int sysctl ([MarshalAs (UnmanagedType.LPArray)] int[] mib, int mibsize, IntPtr output, IntPtr oldLen, IntPtr newp, uint newlen);

    public static Dictionary<String,String> AllMac = null;
    public static String GetMACAddressByIp(String ip)
    {
        return GetMACAddressByIp (ip, false);
    }
    public static String GetMACAddressByIp (String ip, bool reset)
    {
        try 
        {
            if (AllMac == null || reset) 
            {
                AllMac=new Dictionary<string, string>();
                int CTL_NET = 4;
                int PF_ROUTE = 17;
                int AF_INET = 2;
                int NET_RT_FLAGS = 2;
                int RTF_LLINFO = 0x400;
                int[] mib = { CTL_NET, PF_ROUTE, 0, AF_INET, NET_RT_FLAGS, RTF_LLINFO };
                var pLen = Marshal.AllocHGlobal (sizeof(int));
                sysctl (mib, 6, IntPtr.Zero, pLen, IntPtr.Zero, 0);
                var length = Marshal.ReadInt32 (pLen);
                if (length == 0) {
                    Marshal.FreeHGlobal (pLen);
                    return string.Empty;
                }
                var pBuf = Marshal.AllocHGlobal (length);
                sysctl (mib, 6, pBuf, pLen, IntPtr.Zero, 0);
                int off = 0;
                while (true) {
                    short len = Marshal.ReadInt16 (pBuf + off);
                    IntPtr paddr = pBuf + off + 36 + 56;
                    byte sinlen = Marshal.ReadByte (paddr);  
                    uint addr = (uint)Marshal.ReadInt32 (paddr + 4);
                    string ipAddress = new IPAddress (BitConverter.GetBytes (addr)).ToString ();
                    paddr += sinlen; 
                    StringBuilder sb = new StringBuilder ();
                    bool allZero = true;
                    for (int m = 0; m < 6; m++) {
                        byte b = Marshal.ReadByte (paddr + 8 + m);
                        if (b != 0) {
                            allZero = false;
                        }
                        if (sb.Length > 0) {
                            sb.Append (":");
                        }
                        sb.Append (b.ToString ("X2"));
                    }

                    String mac = sb.ToString ();
                    if (!allZero) {
                        AllMac[ipAddress]=mac;
                    }
                    off += len;
                    if (length <= off) {
                        break;
                    }
                }
                Marshal.FreeHGlobal (pLen);
                Marshal.FreeHGlobal (pBuf);
            }
            if (AllMac.ContainsKey (ip)) {
                return AllMac [ip];
            }
        } catch (Exception ex) {
            Console.WriteLine ("Exception in GetMACAddressByIp:" + ex.ToString ());
        }
        return "";
    }