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

[Bug] Segmentation Fault receiving message on WatchOS with debugger attached #7486

Closed
jschroeder-avi opened this issue Nov 22, 2019 · 3 comments
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS
Milestone

Comments

@jschroeder-avi
Copy link

I am developing an Apple Watch app in Xamarin to connect to the iOS side of my existing Xamarin.Forms app. This issue started appearing on the latest versions of Xcode and Xamarin.

When I run the watch project and send a message from the phone using WCSession.DefaultSession.SendMessage(...), the watch app crashes. This usually happens the second time a message is sent, although it varies. When the crash occurs, the debugger immediately exits and no relevant log is printed. It seems to crash in some internal logic, not on any line of my code. I sometimes (~5% of the time) get a crash file generated in "/Users/johns/Library/Logs/DiagnosticReports/", which is how I know the crash is due to a segmentation fault.

I created a sample project to reproduce the issue. The iOS app has a button that sends a message to the watch. Both projects set a WCSessionDelegate and activate the WCSession on startup. The behavior was reproduced on both an iMac and a Macbook. I made a forum post here https://forums.xamarin.com/discussion/174876/segmentation-fault-receiving-message-on-watchos-with-debugger-attached/p1?new=1 and attached the sample project and one of the crash logs.

Any help would be appreciated. Thanks.

My Environment:
=== Visual Studio Community 2019 for Mac ===

Version 8.3.10 (build 2)
Installation UUID: ca9efe8c-cd51-499b-83d0-27b4a235045b
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5)

Package version: 604000208

=== Mono Framework MDK ===

Runtime:
Mono 6.4.0.208 (2019-06/07c23f2ca43) (64-bit)
Package version: 604000208

=== NuGet ===

Version: 5.3.0.6192

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.0.100/Sdks
SDK Versions:
3.0.100
3.0.100-preview8-013656
2.1.701
2.1.700
2.1.505
2.1.301
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.0.0
3.0.0-preview8-28405-07
2.1.13
2.1.12
2.1.11
2.1.9
2.1.1

=== Xamarin.Profiler ===

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

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 10.0.6.2 (Visual Studio Community)
Commit: xamarin-android/d16-3/c407838
Android SDK: /Users/johns/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)

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

Build Information:
Mono: mono/mono@476d72b9e32
Java.Interop: xamarin/java.interop@5836f58
LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94
LibZip: nih-at/libzip@b95cf3fd
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools@cb41333

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/johns/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 1.4.0.65
Hash: c33b107
Branch: remotes/origin/d16-3
Build date: 2019-11-19 20:33:22 UTC

=== Android Device Manager ===

Version: 1.2.0.116
Hash: d2b2af0
Branch: remotes/origin/d16-3
Build date: 2019-11-19 20:33:42 UTC

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

Version: 16.3.0.256
Hash: 8a223bfd7
Branch: remotes/origin/d16-3
Build date: 2019-11-01 21:02:02 UTC

=== Apple Developer Tools ===

Xcode 11.2.1 (15526.1)
Build 11B500

=== Xamarin.Mac ===

Version: 6.6.0.12 (Visual Studio Community)
Hash: e3c2b40
Branch: xcode11.2
Build date: 2019-11-01 00:12:07-0400

=== Xamarin.iOS ===

Version: 13.6.0.12 (Visual Studio Community)
Hash: e3c2b40
Branch: xcode11.2
Build date: 2019-11-01 00:12:08-0400

=== Build Information ===

Release ID: 803100002
Git revision: add3a4998a5cb5b081e0404e1fe13acfecb7801d
Build date: 2019-11-20 13:35:15+00
Build branch: release-8.3
Xamarin extensions: 79c69708816813b498283eeda7bcb4d464433a04

=== Operating System ===

Mac OS X 10.15.1
Darwin 19.0.0 Darwin Kernel Version 19.0.0
Thu Oct 17 16:17:15 PDT 2019
root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64

@StephaneDelcroix StephaneDelcroix transferred this issue from xamarin/Xamarin.Forms Nov 25, 2019
@jschroeder-avi
Copy link
Author

As noted in my forum post, I'm getting a seemingly similar crash on startup in the Xamarin sample https://github.com/xamarin/ios-samples/tree/master/watchOS/SimpleWatchConnectivity . I also rewrote my test project in Xcode/Objective-c, and had no issues.

@chamons chamons added bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS labels Nov 25, 2019
@chamons chamons added this to the Future milestone Nov 25, 2019
@lewurm
Copy link
Contributor

lewurm commented Nov 26, 2019

Thread 7 Crashed:: tid_a10b  Dispatch queue: NSOperationQueue 0x802d29b0 (QOS: UTILITY)
0   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x00378b41 mono_get_hazardous_pointer + 17 (hazard-pointer.c:208)
1   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x0027088a mono_jit_info_table_find_internal + 58 (jit-info.c:295)
2   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x001fcabd debugger_interrupt_critical + 77 (debugger-agent.c:2693)
3   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x0038a457 mono_thread_info_safe_suspend_and_run + 743 (mono-threads.c:1343)
4   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x001fc9d9 notify_thread + 89 (debugger-agent.c:2725)
5   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x002b5bd9 mono_g_hash_table_foreach + 73 (mono-hash.c:310)
6   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x001fad3c suspend_vm + 188 (debugger-agent.c:2822)
7   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x001fee49 process_event + 3097 (debugger-agent.c:3873)
8   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x001f8bd0 thread_startup + 496 (debugger-agent.c:4014)
9   com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x002cabe3 mono_profiler_raise_thread_started + 51 (profiler-events.h:103)
10  com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x002fe98d mono_thread_attach + 253 (threads.c:1115)
11  com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x003082fd mono_threads_attach_coop_internal + 125 (threads.c:6074)
12  com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x003083dc mono_threads_attach_coop + 44 (threads.c:6111)
13  com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x003a2789 xamarin_switch_gchandle + 185 (runtime.m:1851)
14  com.mycompany.WCSessionTest.watchkitapp.watchkitextension	0x003a55be xamarin_retain_trampoline + 78 (trampolines.m:695)
15  libobjc.A.dylib               	0x06aee520 objc_retain + 64
16  com.apple.WatchConnectivity   	0x011eccaa __66-[WCSession onqueue_handleDictionaryMessageRequest:withPairingID:]_block_invoke + 279
17  com.apple.Foundation          	0x051e7df7 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
18  com.apple.Foundation          	0x051e7cf4 -[NSBlockOperation main] + 88
19  com.apple.Foundation          	0x051eacee __NSOPERATION_IS_INVOKING_MAIN__ + 27

this is a problem in the managed debugger of mono. @chamons could you move this to mono/mono?

@chamons
Copy link
Contributor

chamons commented Nov 26, 2019

This issue was moved to mono/mono#17926

@chamons chamons closed this as completed Nov 26, 2019
@xamarin xamarin locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug If an issue is a bug or a pull request a bug fix iOS Issues affecting Xamarin.iOS
Projects
None yet
Development

No branches or pull requests

3 participants