xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.46k stars 511 forks source link

memory-access.c:122, condition `size < MAX_INLINE_COPY_SIZE' not met #9009

Closed james-allison closed 4 years ago

james-allison commented 4 years ago

Steps to Reproduce

  1. Build project for iPhone hardware without the LLVM compiler
  2. Build fails with Xamarin.iOS.Common.targets(842,3): error MT3001: Could not AOT the assembly [Executable name]. 2a. Diagnostic logging reveals AOT Compilation exited with code 134. Assertion at mono/mini/memory-access.c:122, condition `size < MAX_INLINE_COPY_SIZE' not met

Expected Behavior

Build completes and the world is good.

Actual Behavior

Only builds using the LLVM optimizing compiler succeed - (which means I can not debug my project on iOS). This used to build fine on Visual Studio 16.5.x - I think it broke (along with so many other things) switching to 16.6.x. I've tried upgrading the version of Xamarin.iOS.pkg on the mac to 13.20.1.18, but the error remains identical to the version that ships with 16.6.3 (13.18.2.1) Looking at the source for the assertion location in the mono repo (https://github.com/mono/mono/blob/master/mono/mini/memory-access.c) - it is preceded with the comment /*FIXME arbitrary hack to avoid unbound code expansion.*/ - which doesn't fill me with confidence.

Environment

Microsoft Visual Studio Enterprise 2019 (2)
Version 16.6.3
VisualStudio.16.Release/16.6.3+30225.117
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Visual C++ 2019   00433-90000-00004-AA111
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.6.954.58314
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services   16.1.0.2020603+b3ac44798c16fff5b95dbcfe62dea84aa9a1bd72
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019   16.6.954.58314
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.6.954.58314
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.6.954.58314
Azure Functions and Web Jobs Tools

C# Tools   3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
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.

Extensibility Message Bus   1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

JetBrains ReSharper Ultimate 2020.1.3   Build 201.0.20200515.122017
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright Β© 2020 JetBrains, Inc.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30212.1

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines 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 Library Manager   2.1.50+g25aae5a24a.R
Install client-side libraries easily to any web project

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

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   16.6.17 (9692114)
Support for debugging Mono processes with Visual Studio.

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

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   16.0.62006.03190
Microsoft SQL Server Data Tools

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools   16.0.20417.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Cross Platform Mobile Development (Android)   16.0.30014.67
Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Linux Development   1.0.9.30223
Visual C++ for Linux Development

Visual F# Tools 10.9.1.0 for F# 4.7   16.6.0-beta.20217.4+1c969cac25e2d38d71872efe6c8226029e42bb59
Microsoft Visual F# Tools 10.9.1.0 for F# 4.7

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

Visual Studio Container Tools Extensions (Preview)   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Foo   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   16.6.000.1062 (d16-6@41e1f0e)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.6.0.318 (remotes/origin/d16-6@66afc5421)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.6.40 (1f1466f)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   10.3.1.4 (d16-6/3a10de9)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: 165f4b0
    Java.Interop: xamarin/java.interop/d16-6@2cab35c
    ProGuard: xamarin/proguard/master@905836d
    SQLite: xamarin/sqlite/3.31.1@49232bc
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

Xamarin.iOS and Xamarin.Mac SDK   13.18.2.1 (29c4ea7)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

murmur-ios.log

Example Project (If Possible)

Happy to share the obj/Debug folder for the build privately to allow you to reproduce - please get in touch.

chamons commented 4 years ago

Can you please attach the csproj, or at least note what architectures you are building for?

This might be another flavor of issues when your code size is too large for 32-bit.

james-allison commented 4 years ago

I've attached the .csproj and the response-file.rsp from the failed call to mtouch in the logs. The architecture is ARM64 only - so I'd assume not a 32bit issue. I'm attempting to build the iPhone Debug target, though the only configurations which currently work are those using the LLVM compiler - which prohibits use of the debugger.

Murmur.iOS.csproj.txt response-file.rsp.txt

james-allison commented 4 years ago

After further investigation, this appears to have been caused by a change I'd made whilst the 16.6.0 VS Studio release had broken iOS builds - apologies for misleading description earlier, and assuming it was another new problem.

Including the following struct in a shared library prevents non LLVM builds completing on iOS, and causes the LLVM builds to take 6x longer.

Android builds didn't have an issue however.

    [StructLayout(LayoutKind.Explicit)]
    public unsafe struct DenoiseState
    { 
        [FieldOffset(0)]
        public fixed float analysis_mem[480];
        [FieldOffset(1920)]
        public fixed float cepstral_mem[176];
        [FieldOffset(2624)]
        public int memid;
        [FieldOffset(2628)]
        public fixed float synthesis_mem[480];
        [FieldOffset(4548)]
        public fixed float pitch_buf[1728];
        [FieldOffset(11460)]
        public fixed float pitch_enh_buf[1728];
        [FieldOffset(18372)]
        public float last_gain;
        [FieldOffset(18376)]
        public int last_period;
        [FieldOffset(18380)]
        public fixed float mem_hp_x[2];
        [FieldOffset(18388)]
        public fixed float lastg[22];
        [FieldOffset(18476)]
        public RNNState rnn;
    };

    public struct RNNState
    {

    }
whitneyschmidt commented 4 years ago

This issue was moved to mono/mono#20149

whitneyschmidt commented 4 years ago

@james-allison Thank you for providing more info! I've moved this issue over to mono/mono as it doesn't appear to be related to the SDK. You can follow https://github.com/mono/mono/issues/20149 for updates :)