Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MacOS][Xamarin.Forms] View has 16383 views pointing at it that can't be found, SIGSEGV, at <unknown> <0xffffffff> #5445

Closed
Liam2349 opened this issue Jan 20, 2019 · 3 comments
Labels
macOS Issues affecting Xamarin.Mac need-info Waiting for more information before the bug can be investigated support The issue is related to support
Milestone

Comments

@Liam2349
Copy link

Description

I have a Xamarin.Forms app targeting WPF, Android and macOS. On macOS, I'm having a lot of issues with SIGSEGV errors, which for a while now has prevented me from releasing the app as it is not stable.

It seems that these are caused by referencing views that no longer exist. The output window in VS for Mac will say that a view has 16383 views pointing at it that can't be found. It seems that there is something special about this number, because it's in every single output. This number is produced when calculating (int16.MaxValue / 2) and storing it in an integer, so I would assume there's something going on internally with range limitations of int16 values.

I've also read the docs on debugging native exceptions in Xamarin.Mac: https://docs.microsoft.com/en-us/xamarin/mac/deploy-test/debugging-native-crash

Example 2 from the above link explains that "at <0xffffffff>" suggests that this problem is related to working with an object that has been garbage collected. Based on this, I managed to work around one instance of this problem by not deleting views in one of my layouts, as the deletion of views caused this problem to occur very frequently. So, I stopped deleting views in a layout. The added stability I gained from that allowed me to discover this problem in other areas of my app. For example, when popping to the root of a NavigationPage, which in my case causes the created pages to be marked for GC as I do not hold references to them, and I would rather not have to do that as a potential solution.

So this has been a very persistent, very difficult problem for me, as it's causing my macOS app to randomly fail, and as such I cannot release the app. It seems that this issue is in the Xamarin.Mac or Mono framework, but I cannot determine which.

I've experienced null refs in the Xamarin.Forms framework in the past, and there is a blog post by Jon Goldberger that taught me how to step into XF and implement my own fix, and as such I have been able to move past those problems whilst waiting for the fixes to be worked into the official repos. Here's Jon's post: https://blog.xamarin.com/debugging-xamarin-forms/

I have not yet attempted to give Mono the same inside look, though Jon does have a post on it: https://blog.xamarin.com/debugging-xamarin-mono/

I'm going to get around to trying to get a deeper look using that post, but until then, I wanted to get this issue posted. I'd also like to know if anyone is aware of a similar type of guide for stepping into Xamarin.Mac. Using guides like this, I hope to be able to provide more detail on these issues such that they can be fixed.

Finally, please note that I am running macOS as a virtual machine. The machine has been very well behaved in my experience, and I do not consider this to be my issue, but I thought I should mention this for full disclosure.

I do not consider this VM to be my problem as the other software I'm using, like VS for Mac and Sourcetree, seem to function fine. I've also seen similar issues to this reported in the past.

Expected Behavior

Not throwing SIGSEGV.

Actual Behavior

Throwing SIGSEGV.

Environment

I only use VS for Mac when developing the macOS app. The rest is done on Windows.

Visual Studio for Mac:

=== Visual Studio Community 2017 for Mac ===

Version 7.7.3 (build 43)
Installation UUID: c2df4072-4ecd-4433-8424-2bb82d59acd7
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

	Package version: 516000221

=== Mono Framework MDK ===

Runtime:
	Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
	Package version: 516000221

=== NuGet ===

Version: 4.8.0.5385

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	2.1.2
	2.0.7
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
	2.1.302
	2.1.200
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 10.1 (14460.46)
Build 10B61

=== Xamarin.Mac ===

Version: 5.2.1.13 (Visual Studio Community)
Hash: a4332c90
Branch: 
Build date: 2019-01-11 13:08:10-0500

=== Xamarin.Android ===

Version: 9.1.5.1 (Visual Studio Community)
Android SDK: /Users/admin/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		7.0 (API level 24)
		8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.0
SDK Build Tools Version: 27.0.3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/admin/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9
openjdk version "1.8.0-9"
OpenJDK Runtime Environment (build 1.8.0-9-microsoft-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 7.7.1.0
Hash: 06ceaea1

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Xamarin.iOS ===

Version: 12.2.1.13 (Visual Studio Community)
Hash: a4332c90
Branch: d15-9
Build date: 2019-01-11 13:08:09-0500

=== Build Information ===

Release ID: 707030043
Git revision: 5896ab2acba037c62271742e9e56b900c96c1d8f
Build date: 2019-01-15 21:18:33+00
Build branch: release-7.7
Xamarin extensions: e5b43ba963b7b407aa5b9f2c59018c32a709e6ab

=== Operating System ===

Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
    Wed Aug 22 20:13:40 PDT 2018
    root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64


Output Example

Foreword:

  1. Clipboard Everywhere is the name of my app
  2. You may notice parts of this output that look like the app has hung, and that is what usually happens after the null ref is thrown out of the Main method. I believe this could be because once the exception is thrown, I attempt to log it, but by this point the app seems to be completely broken such that logging is not capable of functioning.

I have seen others complain of SQLite, though not recently, and I am using SQLite.

2019-01-19 13:34:03.372 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e23f20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.372 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e23f20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.372 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e11040> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.372 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e11040> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.373 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e17b60> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.373 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e17b60> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.373 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e16760> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.373 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e16760> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.374 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e15360> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.374 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e15360> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.374 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2bf20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.374 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2bf20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.375 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e37700> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.375 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e37700> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.375 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2ab20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.375 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2ab20> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.376 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e29720> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.376 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e29720> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.376 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e28320> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.376 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e28320> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.377 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2eee0> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.377 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2eee0> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.377 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2dae0> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.377 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2dae0> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.377 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2c640> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.378 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e2c640> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.378 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e22d00> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.378 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e22d00> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.378 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_FormsNSImageView: 0x600003e33200> has 16383 views pointing at it that can't be found.
2019-01-19 13:34:03.383 Clipboard Everywhere[4635:143645] View <NSProgressIndicator: 0x6000034edf00> has 1 views pointing at it that can't be found.
2019-01-19 13:34:03.383 Clipboard Everywhere[4635:143645] View <NSProgressIndicator: 0x6000034edf00> has 1 views pointing at it that can't be found.
2019-01-19 13:34:03.384 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_LayoutRenderer: 0x600003e32e40> has 1 views pointing at it that can't be found.
2019-01-19 13:34:03.384 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_LayoutRenderer: 0x600003e32f80> has 1 views pointing at it that can't be found.
2019-01-19 13:34:03.385 Clipboard Everywhere[4635:143645] View <Xamarin_Forms_Platform_MacOS_LayoutRenderer: 0x600003e23d40> has 1 views pointing at it that can't be found.
Stacktrace:

at <0xffffffff>
at (wrapper managed-to-native) AppKit.NSApplication.NSApplicationMain (int,string[]) [0x0005a] in <009dd37ad4bb49138cd9dd53bef86d07>:0
at AppKit.NSApplication.Main (string[]) [0x00040] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/AppKit/NSApplication.cs:100
at ClipboardEverywhere.Mac.MainClass/

d__0.MoveNext () [0x0007a] in /Users/admin/UniversalClipboard/ClipboardEverywhere.Mac/Main.cs:30
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine_REF> (TStateMachine_REF&) [0x0002c] in /Library/Frameworks/Xamarin.Mac.framework/Versions/5.2.1.13/src/Xamarin.Mac/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:316
at ClipboardEverywhere.Mac.MainClass.Main (string[]) [0x0002a] in <47cbbdd44dce4bdbadd3a2bbd35ce7cb>:0
at ClipboardEverywhere.Mac.MainClass. (string[]) [0x00001] in <47cbbdd44dce4bdbadd3a2bbd35ce7cb>:0
at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) [0x00051] in <47cbbdd44dce4bdbadd3a2bbd35ce7cb>:0

Native stacktrace:

0   Clipboard Everywhere                0x000000010617c208 mono_handle_native_crash + 264
1   Clipboard Everywhere                0x00000001060f9086 altstack_handle_and_restore + 70
2   libobjc.A.dylib                     0x00007fff75b2da1d objc_msgSend + 29
3   AppKit                              0x00007fff471c819c -[NSView _removeFromKeyViewLoop] + 203
4   AppKit                              0x00007fff471c7b4d -[NSView _finalize] + 892
5   AppKit                              0x00007fff471c764a -[NSView dealloc] + 209
6   Clipboard Everywhere                0x000000010608796b xamarin_invoke_objc_method_implementation + 59
7   Clipboard Everywhere                0x0000000106087c0c xamarin_release_trampoline + 156
8   libobjc.A.dylib                     0x00007fff75b30c8c _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 726
9   CoreFoundation                      0x00007fff49b42e76 _CFAutoreleasePoolPop + 22
10  Foundation                          0x00007fff4bee9b8e -[NSAutoreleasePool drain] + 144
11  AppKit                              0x00007fff470bf7cc -[NSApplication run] + 810
12  AppKit                              0x00007fff470aee97 NSApplicationMain + 780
13  ???                                 0x000000010d66540e 0x0 + 4519777294
14  ???                                 0x000000010d66513b 0x0 + 4519776571
15  ???                                 0x0000000106bd38af 0x0 + 4408031407
16  ???                                 0x0000000106bca023 0x0 + 4407992355
17  Clipboard Everywhere                0x0000000106190501 mono_jit_runtime_invoke + 1441
18  Clipboard Everywhere                0x000000010628bebf mono_runtime_invoke_checked + 127
19  Clipboard Everywhere                0x0000000106292d3e mono_runtime_exec_main_checked + 110
20  Clipboard Everywhere                0x00000001060ef0b9 mono_jit_exec + 297
21  Clipboard Everywhere                0x00000001060f20b4 mono_main + 11156
22  Clipboard Everywhere                0x000000010608f349 xamarin_main + 1305
23  Clipboard Everywhere                0x0000000106090314 main + 36
24  libdyld.dylib                       0x00007fff76c0a085 start + 1

Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.kk5S7y'
Executing commands in '/tmp/mono-gdb-commands.kk5S7y'.
(lldb) process attach --pid 4635
Thread finished: #36
Thread finished: #38
Thread finished: #25
13:34:10.8237220 - 1aa4a65e-b8a6-4ab4-8036-8dff978282f5 - SSE: OnMessage(Data: {})
Thread finished: #2
Thread started: #41
Thread finished: #27
Thread finished: #23
13:34:20.8357810 - 1aa4a65e-b8a6-4ab4-8036-8dff978282f5 - SSE: OnMessage(Data: {})
Thread finished: #4
Process 4635 stopped

  • thread make install does not work unless make all is already complete #1, name = 'tid_307', queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
    frame #0: 0x00007fff76d47c5a libsystem_kernel.dylib__wait4 + 10 libsystem_kernel.dylib__wait4:
    -> 0x7fff76d47c5a <+10>: jae 0x7fff76d47c64 ; <+20>
    0x7fff76d47c5c <+12>: movq %rax, %rdi
    0x7fff76d47c5f <+15>: jmp 0x7fff76d42e31 ; cerror
    0x7fff76d47c64 <+20>: retq
    Target 0: (Clipboard Everywhere) stopped.

Executable module set to "/Users/admin/UniversalClipboard/ClipboardEverywhere.Mac/bin/Debug/Clipboard Everywhere.app/Contents/MacOS/Clipboard Everywhere".
Architecture set to: x86_64h-apple-macosx.
(lldb) thread list
Process 4635 stopped

=================================================================
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.

@spouliot spouliot added macOS Issues affecting Xamarin.Mac need-info Waiting for more information before the bug can be investigated support The issue is related to support labels Jan 21, 2019
@spouliot spouliot added this to the Future milestone Jan 21, 2019
@spouliot
Copy link
Contributor

The message View <XXX> has YYY views pointing at it that can't be found. comes from macOS (not Xamarin) even if it's not one I remember seeing previously.

It's likely you're hitting an internal limit set by the operating system because you are keeping references to existing views (preventing the GC to free them). IOW the number keeps increasing until you hit the OS limit and then things go bad (because the OS probably do not let additional instance be allocated).

With the limited information my best advice is to use Xamarin Profiler (or Instruments) and find out where those views are allocated and why they are not released.

If you can create a test case (e.g. subset of your application) that shows the issue then we might be able to investigate this further.

@Liam2349
Copy link
Author

Thanks for the response. I don't believe I have access to Xamarin Profiler, unfortunately, as I don't have a VS Enterprise license.

Based on what you've said, my best guess would be that Xamarin.Forms or Xamarin.Mac is holding these references. 16k views sounds like a lot to be creating - I'm certainly not creating that number intentionally. Perhaps the way that my custom controls are being created could be causing Xamarin.Forms to create a lot of views.

I will try to create a repro case.

@spouliot
Copy link
Contributor

I'm closing the issue since we lack a test case to reproduce it.

If you are still experiencing this issue please provide all the requested information then click the Reopen Issue button.

Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators May 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
macOS Issues affecting Xamarin.Mac need-info Waiting for more information before the bug can be investigated support The issue is related to support
Projects
None yet
Development

No branches or pull requests

2 participants