Skip to content

iOS release build: "Could not AOT the assembly" -> "p - buf < buf_size not met" #7637

Closed

Description

@dalexsoto

From @Amenti on March 15, 2018 15:20

Steps to Reproduce

I can't provide the repository to reproduce this, sorry. It is a complex project though and I can reproduce it by building a release build with Visual Studio for Windows and Mac.

Expected Behavior

Proper AppStore release build for iOS.

Actual Behavior

Build is canceled with the error:

Could not AOT assembly ...

11>  * Assertion at /Users/builder/data/lanes/5808/1c6f300e/source/xamarin-macios/external/mono/mono/mini/aot-compiler.c:6320, condition `p - buf < buf_size' not met

I tried downgrading Visual Studio for Windows and also to build an older source code revision (which is available in the app store) but I can't build it anymore due to the error.

The debug build works fine and also runs in the simulator.

Environment

Windows

Microsoft Visual Studio Professional 2017 
Version 15.6.2
VisualStudio.15.Release/15.6.2+27428.2005
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Professional

Visual F# Tools 10.1 for F# 4.1   00369-60000-00001-AA466
Microsoft Visual F# Tools 10.1 for F# 4.1

Application Insights Tools for Visual Studio Package   8.11.10212.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.40301.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

Azure App Service Tools v3.0.0   15.0.40215.0
Azure App Service Tools v3.0.0

C# Tools   2.7.0-beta3-62707-11. Commit Hash: 75dfc9b33ed624dff3985c7435c902c3c58c0e5c
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.9.11-pre (71eb098)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61801.210
Microsoft SQL Server Data Tools

TypeScript Tools   15.6.20202.3
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.7.0-beta3-62707-11. Commit Hash: 75dfc9b33ed624dff3985c7435c902c3c58c0e5c
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Universal Windows Apps   15.0.27428.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   4.9.0.749 (9b0fce36d)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.10.58 (cee1369d0)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   8.2.0.15 (HEAD/22d97e153)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.8.0.20 (1c6f300)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

MacOs

=== Visual Studio Professional 2017 for Mac ===Version 7.4 (build 1033)

Installation UUID: fb92161a-7228-408e-93c8-1c3578aa5a59

Runtime:

    Mono 5.8.0.129 (2017-10/835a98d8559) (64-bit)

    GTK+ 2.24.23 (Raleigh theme)    Package version: 508000129=== NuGet ===Version: 4.3.1.4445=== .NET Core ===Runtime: /usr/local/share/dotnet/dotnet

Runtime Versions:

    2.0.5

    2.0.0

    1.0.1

SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks

SDK Versions:

    2.1.4

    2.0.0

    1.0.0-preview2-003131

MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/msbuild/15.0/bin/Sdks=== Xamarin.Profiler ===Version: 1.6.1

Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler=== Xamarin.Android ===Version: 8.2.0.15 (Visual Studio Professional)

Android SDK: /Users/dannywernicke_privat/Library/Developer/Xamarin/android-sdk-macosx

    Supported Android versions:

        4.0.3 (API level 15)

        6.0   (API level 23)

        7.1   (API level 25)SDK Tools Version: 25.2.5

SDK Platform Tools Version: 25.0.3

SDK Build Tools Version: 23.0.2Java SDK: /usr

java version "1.7.0_71"

Java(TM) SE Runtime Environment (build 1.7.0_71-b14)

Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)Android Designer EPL code available here:

https://github.com/xamarin/AndroidDesigner.EPL=== Apple Developer Tools ===Xcode 8.3.3 (12175.1)

Build 8E3004b=== Xamarin.Mac ===Version: 4.2.0.20 (Visual Studio Professional)=== Xamarin.iOS ===Version: 11.8.0.20 (Visual Studio Professional)

Hash: 1c6f300e

Branch: d15-6

Build date: 2018-02-07 23:42:40-0500=== Xamarin Inspector ===Version: 1.4.0

Hash: b3f92f9

Branch: master

Build date: Fri, 19 Jan 2018 22:00:34 GMT

Client compatibility: 1=== Build Information ===Release ID: 704001033

Git revision: 053991068f3c88497d3e5cc52fe7fdf57c28b62f

Build date: 2018-02-28 05:02:28-05

Xamarin addins: cc3283953e0af0b8bfab1bdfdf847d9e403c4606

Build lane: monodevelop-lion-d15-6=== Operating System ===Mac OS X 10.13.3

Darwin 17.4.0 Darwin Kernel Version 17.4.0

   Sun Dec 17 09:19:54 PST 2017

   root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64=== Enabled user installed addins ===Internet of Things (IoT) development (Preview) 7.1

Build Logs

Buildlog

Copied from original issue: dotnet/macios#3756

Activity

  1. dalexsoto commented on Mar 15, 2018

    @dalexsoto
    MemberAuthor

    From @rolfbjarne on March 15, 2018 16:15

    @Amenti are you able to provide compiled assemblies? In particular I believe we'll be able to reproduce this if we can get the contents of the /Users/dannywernicke_privat/Library/Caches/Xamarin/mtbs/builds/TeacherStudio.XamarinForms.iOS/4242f4ff0d90da2fbec3ed128c40cbf4/obj/iPhone/AppStore/mtouch-cache directory, which only contain assemblies and other intermediate build files (but no source code).

  2. dalexsoto commented on Mar 15, 2018

    @dalexsoto
    MemberAuthor

    From @Amenti on March 15, 2018 16:33

    Great, thanks a lot. 👍 I did send you an email with a link to the files.

  3. dalexsoto commented on Mar 15, 2018

    @dalexsoto
    MemberAuthor

    From @rolfbjarne on March 15, 2018 17:30

    Private test case stored here: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/583998. To repro: download attached zip and execute build.sh.

  4. added this to the 2017-12 (5.10.xx) milestone on Mar 15, 2018
  5. spouliot commented on Mar 15, 2018

    @spouliot
    Contributor

    @vargaz from the description this seems to be a regression

  6. rolfbjarne commented on Mar 15, 2018

    @rolfbjarne
    Member
  7. Amenti commented on Mar 17, 2018

    @Amenti

    Wow, you fixed that very fast. Thanks a lot. Is there any way to workaround this issue for me until this fix is released?

  8. lewurm commented on Mar 18, 2018

    @lewurm
    Contributor

    @Amenti You asked for it... though, I don't recommend this for production. Use it at your own risk. I'm assuming you are using macOS.

    We gonna binary patch the AOT compiler. First, let's make a backup:


    $ export AOTC=/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/arm64-darwin-mono-sgen
    
$ sudo cp $AOTC{,.BACKUP}

    

    Let’s look for the offset we need to patch:


    $ objdump -disassemble $AOTC | grep '8d 8c 11 00 08 00 00'
    1000918a6:	8d 8c 11 00 08 00 00 	leal	2048(%rcx,%rdx), %ecx


    This instruction determines the value passed to malloc, which we wanna increase. Before that, let's 


verify the location in the actual binary (0x918a6 is potentially different in your case):

    $ xxd -s 0x918a6 $AOTC | head -n 1
    000918a6: 8d8c 1100 0800 0089 8d88 f4ff ff48 63f9  .............Hc.

    

    And now let’s patch it and verify again:


    
$ echo "918a6: 8d8c 1100 1f 00 00" | xxd -r - $AOTC

    $ xxd -s 0x918a6 $AOTC | head -n 1
    000918a6: 8d8c 1100 1f00 0089 8d88 f4ff ff48 63f9  .............Hc.


    we replaced 0x800 (2048) with 0x1f00 (7936). Dirty workaround, but that's sufficient for the repro that was provided.

  9. vargaz commented on Mar 18, 2018

    @vargaz
    Contributor

    There is an async method named Import somewhere in EarlyNerds.TeacherStudio.ViewModels.SyncSettingsViewModel. Simplifying it, or moving parts of it to another method could probably work around the problem.

  10. Amenti commented on Mar 18, 2018

    @Amenti

    @vargaz @lewurm Thanks a lot for all your help! Reducing the mentioned method did help. 🥇

  11. added a commit that references this issue on Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions