Bug 57320 - condition new_val < (1 << ABORT_PROT_BLOCK_BITS) not met
Summary: condition new_val < (1 << ABORT_PROT_BLOCK_BITS) not met
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: 5.0 (2017-02)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
URL:
: 59574 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-06-09 13:56 UTC by Mike Bayles
Modified: 2017-10-23 13:41 UTC (History)
7 users (show)

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


Attachments

Description Mike Bayles 2017-06-09 13:56:47 UTC
I just upgraded to Xamarin.Android 7.3.1.2 and my app is crashing on startup with the following error:

Assertion at /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mono/metadata/threads.c:266, condition 'new_val < (1 << ABORT_PROT_BLOCK_BITS)' not met

This was deployed to a device running Android 7.1.1
Comment 1 Mike Bayles 2017-06-09 14:38:33 UTC
One thing I noticed was that removing some references alleviates the problem
Comment 2 Mike Bayles 2017-06-12 15:38:00 UTC
Here is my version information from Visual Studio:

Microsoft Visual Studio Professional 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Professional

LightSwitch for Visual Studio 2015   00322-40000-00000-AA468
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-40000-00000-AA468
Microsoft Visual Basic 2015

Visual C# 2015   00322-40000-00000-AA468
Microsoft Visual C# 2015

Visual C++ 2015   00322-40000-00000-AA468
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015 (RC1 Update 1)   14.1.20203.0
ASP.NET and Web Tools 2015 (RC1 Update 1)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

AWS Toolkit for Visual Studio 2015   1.11.7.6
AWS Toolkit for Visual Studio 2015.
Copyright 2011-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License 
  [http://logging.apache.org/log4net/license.html]
- Putty for PPK to PEM conversion, MIT license 
  [http://www.chiark.greenend.org.uk/~sgtatham/putty/licence.html]
- NGit for AWS Elastic Beanstalk incremental push
  [https://github.com/mono/ngit/blob/master/NGit.license.txt]
- NSch dependency for NGit
  [https://github.com/mono/ngit/blob/master/NSch.license.txt]
- Sharpen dependency for NGit
  [https://github.com/mono/ngit/blob/master/Sharpen/AssemblyInfo.cs]
- ICSharpCode.SharpZipLib dependency for NGit
  [http://www.icsharpcode.net/opensource/sharpziplib/]
- Mono.Posix.dll and Mono.Security.dll dependencies for NGit
  [http://mono-project.com/FAQ:_Licensing#Licensing]
- MPFProj for Visual Studio Project Framework
  [http://mpfproj10.codeplex.com/license]
- JSON Checker for JSON validation
  [http://www.raboof.com/projects/jsonchecker/]

Azure App Service Tools v3.0.0   14.0.30222.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.6000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.6000.1
Microsoft Azure Data Lake Tools for Visual Studio

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

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

Microsoft Azure HDInsight Azure Node   2.2.6000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.2.6000.1
Language service for Hive query

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Microsoft Azure Stream Analytics Language Service   2.2.6000.1
Language service for Azure Stream Analytics

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2015 - v2.9.50504.2

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

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

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   1.8.29.0
TypeScript tools for Visual Studio

Xamarin   4.5.0.476 (1be4f0c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.3.1.2 (9dbc4c5)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.10.0.35 (4cffddf)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 3 Mike Bayles 2017-06-12 19:49:56 UTC
Here is some of the stacktrace:

 JNI RegisterNativeMethods: attempt to register 0 native methods for md5a0cf020ae376354a29a382fcefa05ee5.FoundationServiceBinder
06-09 16:05:34.678  3040  3058 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md5d0106075ed6fdae12e81cc2b59d56657.PtpSession
06-09 16:05:34.780  3040  3058 I art     : Starting a blocking GC Explicit
06-09 16:05:34.813  3040  3058 I art     : Explicit concurrent mark sweep GC freed 5777(292KB) AllocSpace objects, 0(0B) LOS objects, 42% free, 1398KB/2MB, paused 421us total 33.110ms
06-09 16:05:36.850  3002  3038 I art     : Starting a blocking GC Explicit
06-09 16:05:36.889  3002  3038 I art     : Explicit concurrent mark sweep GC freed 2140(446KB) AllocSpace objects, 2(168KB) LOS objects, 39% free, 2MB/4MB, paused 609us total 38.112ms
06-09 16:05:37.596  3002  3038 I art     : Starting a blocking GC Explicit
06-09 16:05:37.633  3002  3038 I art     : Explicit concurrent mark sweep GC freed 806(534KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 2MB/4MB, paused 554us total 36.238ms
06-09 16:05:38.577  3002  3038 I art     : Starting a blocking GC Explicit
06-09 16:05:38.614  3002  3038 I art     : Explicit concurrent mark sweep GC freed 507(869KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 2MB/4MB, paused 516us total 36.426ms
06-09 16:05:38.823  3002  3038 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md51765bfa0bf717110e13d6c4eebf63190.Control
06-09 16:05:38.830  3002  3038 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md51765bfa0bf717110e13d6c4eebf63190.PictureBox
06-09 16:05:38.833  3002  3038 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md51765bfa0bf717110e13d6c4eebf63190.Form
06-09 16:05:38.835  3002  3038 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md5b198ffd1ce454c991fe5a36f2642e74c.MainForm
06-09 16:05:38.958  3002  3038 W art     : JNI RegisterNativeMethods: attempt to register 0 native methods for md51765bfa0bf717110e13d6c4eebf63190.CheckBox
06-09 16:05:40.036  3002  3038 F         : * Assertion at /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mono/metadata/threads.c:266, condition `new_val < (1 << ABORT_PROT_BLOCK_BITS)' not met
--------- beginning of crash
06-09 16:05:40.037  3002  3038 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 3038 (Thread-6)
06-09 16:05:40.047   208   208 W         : debuggerd: handling request: pid=3002 uid=10075 gid=10075 tid=3038
06-09 16:05:40.165  3074  3074 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-09 16:05:40.165  3074  3074 F DEBUG   : Revision: '0'
06-09 16:05:40.165  3074  3074 F DEBUG   : ABI: 'arm'
06-09 16:05:40.165  3074  3074 F DEBUG   : pid: 3002, tid: 3038, name: Thread-6  >>> MyApp.Me <<<
06-09 16:05:40.165  3074  3074 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
06-09 16:05:40.169  3074  3074 F DEBUG   : Abort message: '* Assertion at /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mono/metadata/threads.c:266, condition `new_val < (1 << ABORT_PROT_BLOCK_BITS)' not met
06-09 16:05:40.169  3074  3074 F DEBUG   : '
06-09 16:05:40.169  3074  3074 F DEBUG   :     r0 00000000  r1 00000bde  r2 00000006  r3 00000008
06-09 16:05:40.169  3074  3074 F DEBUG   :     r4 7c4f7978  r5 00000006  r6 7c4f7920  r7 0000010c
06-09 16:05:40.169  3074  3074 F DEBUG   :     r8 7bd54d18  r9 00013464  sl 7c43d094  fp 7c43d008
06-09 16:05:40.169  3074  3074 F DEBUG   :     ip 00000002  sp 7c43cfb8  lr acbb9447  pc acbbbca4  cpsr 200e0010
06-09 16:05:40.186  3074  3074 F DEBUG   : 
06-09 16:05:40.186  3074  3074 F DEBUG   : backtrace:
06-09 16:05:40.186  3074  3074 F DEBUG   :     #00 pc 00049ca4  /system/lib/libc.so (tgkill+12)
06-09 16:05:40.186  3074  3074 F DEBUG   :     #01 pc 00047443  /system/lib/libc.so (pthread_kill+34)
06-09 16:05:40.186  3074  3074 F DEBUG   :     #02 pc 0001d745  /system/lib/libc.so (raise+10)
06-09 16:05:40.186  3074  3074 F DEBUG   :     #03 pc 00019291  /system/lib/libc.so (__libc_android_abort+34)
06-09 16:05:40.186  3074  3074 F DEBUG   :     #04 pc 00017034  /system/lib/libc.so (abort+4)
06-09 16:05:40.186  3074  3074 F DEBUG   :     #05 pc 0029d728  /data/app/MyApp.Me-1/lib/arm/libmonosgen-2.0.so
Comment 4 Rodrigo Kumpera 2017-06-20 21:15:20 UTC
Please provide a test case that would allow us to reproduce your bug.
Comment 5 Mike Bayles 2017-06-21 13:54:36 UTC
If you can mark this bug private, I can share some detailed logs
Comment 6 uaxen 2017-07-05 14:03:50 UTC
There is a related bug in the older version of Xamarin that we are currently using. During a debug session, we have to remove one or more "plugin" references, otherwise the app crashes (during debug only). It crashes in the same place as the above crash. The difference is that the above crash now happens even when the debugger is not attached.

Do you have everything you need from us to debug this? You should have a test apk that crashes on launch.

Current configuration, where the crash occurs during a debug session:
Microsoft Visual Studio Enterprise 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Enterprise

Architecture and Modeling Tools   00322-80000-00000-AA811
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015   00322-80000-00000-AA811
Microsoft Visual Basic 2015

Visual C# 2015   00322-80000-00000-AA811
Microsoft Visual C# 2015

Visual C++ 2015   00322-80000-00000-AA811
Microsoft Visual C++ 2015

Windows Phone SDK 8.0 - ENU   00322-80000-00000-AA811
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11106.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Command Bus, Event Stream and Async Manager   Merq
Provides ICommandBus, IEventStream and IAsyncManager MEF services for loosely coupled Visual Studio extension components communication and integration.

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

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

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

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60519.0
Microsoft SQL Server Data Tools

TypeScript   1.8.36.0
TypeScript tools for Visual Studio

Xamarin   4.2.2.11 (00fa5cc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   7.0.2.42 (501e63c)
Visual Studio extension to enable development for Xamarin.Android.

Xamarin.iOS   10.3.1.8 (7beaef4)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 7 uaxen 2017-07-19 13:43:04 UTC
This bug still says NEEDSINFO, but we have provided a debug apk. We are currently unable to target Android 7, and this is impacting our business. Could we please get an update on this bug?
Comment 8 uaxen 2017-08-11 01:01:18 UTC
We have a workaround for this. We had to remove some of the references to assemblies (.csproj) that contained Android fragments, and we pulled the .cs and resource files for those projects into the project that contains the MainActivity.


This crash appears to be triggered when Android Resources are being accessed (for example, with the layoutInflater). The generated Resource.Designer.cs file in our main project is huge, with many mapping of resource id's from different assemblies to the main assembly. Because of the way the solution was originally developed (in Windows) using a plugins architecture, Android fragments are defined in many different assemblies (plugins). As a result, we have a huge list of resource id mappings from many outside assemblies to the main assembly, and when the resources id's are accessed, Xamarin goes through a long list of loading assemblies (assembly ref load assembly... etc.) At that point it crashed with the above error. To complicate things, many plugins referenced another common assembly which contains Android resources, and those were duplicated in the mapping for each of those assemblies....

Hopefully this information will help you to find the root cause of the Mono crash.
Comment 9 uaxen 2017-08-11 16:52:01 UTC
Here is an example of the Assembly Ref addref that appears repeatedly:
Assembly Ref addref someAssembly[0xa72d5340] -> anotherAssembly[0xa4c10e20]: 21
Comment 10 Jon Goldberger [MSFT] 2017-09-18 19:54:50 UTC
@uaxen,

I do not see any apk attached to this bug report. You said you provided such... how did you provide it? If you tried to attach it to this bug report, and the attachment was greater than ~10MB the attachment would have failed.
Comment 11 uaxen 2017-09-18 20:38:36 UTC
Mike Bayles supplied it privately to someone on your team. I'll ask him to comment
Comment 12 Mike Bayles 2017-09-18 20:49:23 UTC
I provided the APK via a Google Drive link privately to Rodrigo Kumpera via email
Comment 13 uaxen 2017-09-18 20:53:11 UTC
@jon.goldberger, Let us know if we should send the apk to you or supply the link on this bug (once it is private), thanks
Comment 14 Jon Goldberger [MSFT] 2017-09-18 20:56:18 UTC
In Light of comment 12 above and that another user [1] is hitting the same error, I am setting the status to "confirmed".

[1] https://forums.xamarin.com/discussion/comment/294876/#Comment_294876
Comment 15 Jon Goldberger [MSFT] 2017-09-18 21:08:45 UTC
@uaxen

I am a support engineer and am not in a position to fix this sort of mono issue. I am getting involved as the other person who posted on that forum thread also sent in a support request, I found this bug report and though I would try to help move it forward if possible. 

I could set this report to private but there is advantage to having it public (as others might hit the issue). What you could do is file a new bug report as a private report, add your link, etc, and mark it as a duplicate of this bug report. The other bug report would remain visible only to the bug reporter and the Xamarin team. You could then add a private comment on this report letting the engineers know that you provided an apk in the other bug report.
Comment 16 Mike Bayles 2017-09-19 01:16:38 UTC
I have created the new private bug: https://bugzilla.xamarin.com/show_bug.cgi?id=59574
Comment 17 Jon Goldberger [MSFT] 2017-09-19 01:17:45 UTC
*** Bug 59574 has been marked as a duplicate of this bug. ***
Comment 18 elhajjaji.anas@gmail.com 2017-10-09 10:29:50 UTC
I'm facing the same issue using Xamarin.Android 7.4, I have an application with about 130 libraries (as NuGet packages), just reducing the number of references the application starts without problem. When I downgrade Xamarin.Android to 7.2.0.7 the applications starts and I noticed that the size of the APK is two times bigger as before. Thanks to Jon, we tested many things but with no success for the moment. Could you please work on that issue because it's currently blocking us. And for privacy matter, I cannot share the source code of the application. Is there any extended mono logs that we cas use to have more details about the bug?
Comment 19 elhajjaji.anas@gmail.com 2017-10-12 08:03:04 UTC
Following are my logcat:
W/ActivityManager(  876): Launch timeout has expired, giving up wake lock!
I/PowerManagerService(  876): setBrightness mButtonLight 0.
F/        ( 4462): * Assertion at /Users/builder/jenkins/workspace/xamarin-android/xamarin-android/external/mono/mono/metadata/threads.c:259, condition `new_val < (1 << ABORT_PROT_BLOCK_BITS)' not met
F/libc    ( 4462): Fatal signal 6 (SIGABRT), code -6 in tid 4462 (Morpho.Mims)
I/libc    ( 4462): Suppressing debuggerd output because prctl(PR_GET_DUMPABLE)==0
I/Zygote  (  350): Process 4462 exited due to signal (6)
I/ActivityManager(  876): Process xxx (pid 4462) has died

I noticed the message:
W/ActivityManager(  876): Launch timeout has expired, giving up wake lock!

So since I have multiple libraries, the application is very slow to start even if the first activity is only an empty screen with no processing.

In the application output I have a lot of checks during application startup like:
Loaded assembly: xxx.dll (that means all the assemblies should be loaded even if they will be used later, this should be very slow... ??)

AND
[Mono] Assembly Ref addref xxx[0xb74c4df0] -> Mono.Android[0xb752d1d8]: 34

What I find strange is in Xamari.Android 7.2 there is no issue but in 7.3 and above the issue is appearing...

Could you please fix this since it's blocking us for a long time...
Comment 20 elhajjaji.anas@gmail.com 2017-10-22 16:50:08 UTC
Finally, after cleaning the resources and making some optimisations in my libraries I was able to reduce the size of Resource.designer.cs of my application from 12mb to 6mb and the application is now starting correctly. The issue was obviously coming from the fact that Resource.designer.cs is huge. We were in the same situation in the past but now Mono doesn't accept this...
Comment 21 uaxen 2017-10-23 13:41:08 UTC
Yes that is the way I solved it as well. It's frustrating when the app breaks from one Xamarin version to the next, particularly when it is as hard to diagnose/fix as this. Glad you were able to solve it, and Xamarin, this is still a Mono bug.

Note You need to log in before you can comment on or make changes to this bug.