Bug 37272 - App Fails to connect to debugger when linking to a static C++ library.
Summary: App Fails to connect to debugger when linking to a static C++ library.
Status: RESOLVED ANSWERED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 2.4.0 (C6)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris Hamons
URL:
Depends on:
Blocks:
 
Reported: 2015-12-23 20:51 UTC by Jon Goldberger [MSFT]
Modified: 2016-01-05 19:33 UTC (History)
2 users (show)

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


Attachments
Output from Terminal run (4.83 KB, application/zip)
2015-12-23 20:51 UTC, Jon Goldberger [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Jon Goldberger [MSFT] 2015-12-23 20:51:29 UTC
Created attachment 14396 [details]
Output from Terminal run

## Description

When trying to link to a static C++ library, the debugger fails to connect with message:

>debugger-agent: Unable to connect to 127.0.0.1:62286

When running in Release config (no debugger), this stack trace is output:

>Unhandled Exception:
>System.Net.Sockets.SocketException: Could not resolve host 'Jons-iMac.local'
>  at System.Net.Dns.Error_11001 (System.String hostName) <0x10d29e690 + 0x0008c> in <filename unknown>:0 
>  at System.Net.Dns.hostent_to_IPHostEntry (System.String originalHostName, System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) <0x10d29c0f0 + 0x00289> in <filename unknown>:0 
>  at System.Net.Dns.GetHostByName (System.String hostName) <0x10d1ee090 + 0x00089> in <filename unknown>:0 
>  at CL.CLUtils.getLocalip () <0x1088dce40 + 0x00024> in <filename unknown>:0 
>  at GUI.MainWindow.testmanaged () <0x1088dce10 + 0x00010> in <filename unknown>:0 
>  at GUI.MainWindow.cpinitialize () <0x1088dcdc0 + 0x00017> in <filename unknown>:0 
>  at GUI.MainWindow.AwakeFromNib () <0x1088dcc20 + 0x00027> in <filename unknown>:0 
>  at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
>  at AppKit.NSWindowController.get_Window () <0x1088d9410 + 0x0009e> in <filename unknown>:0 
>  at GUI.MainWindowController.get_Window () <0x1088d9390 + 0x00017> in <filename unknown>:0 
>  at GUI.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) <0x1088d6980 + 0x0008c> in <filename unknown>:0 
>  at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
>  at AppKit.NSApplication.Main (System.String[] args) <0x1088d0d50 + 0x000c3> in <filename unknown>:0 
>  at GUI.MainClass.Main (System.String[] args) <0x1005dae50 + 0x00025> in <filename unknown>:0 
>[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Sockets.SocketException: Could not resolve host 'Jons-iMac.local'
>  at System.Net.Dns.Error_11001 (System.String hostName) <0x10d29e690 + 0x0008c> in <filename unknown>:0 
>  at System.Net.Dns.hostent_to_IPHostEntry (System.String originalHostName, System.String h_name, System.String[] h_aliases, System.String[] h_addrlist) <0x10d29c0f0 + 0x00289> in <filename unknown>:0 
>  at System.Net.Dns.GetHostByName (System.String hostName) <0x10d1ee090 + 0x00089> in <filename unknown>:0 
>  at CL.CLUtils.getLocalip () <0x1088dce40 + 0x00024> in <filename unknown>:0 
>  at GUI.MainWindow.testmanaged () <0x1088dce10 + 0x00010> in <filename unknown>:0 
>  at GUI.MainWindow.cpinitialize () <0x1088dcdc0 + 0x00017> in <filename unknown>:0 
>  at GUI.MainWindow.AwakeFromNib () <0x1088dcc20 + 0x00027> in <filename unknown>:0 
>  at (wrapper managed-to-native) ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper (intptr,intptr)
>  at AppKit.NSWindowController.get_Window () <0x1088d9410 + 0x0009e> in <filename unknown>:0 
>  at GUI.MainWindowController.get_Window () <0x1088d9390 + 0x00017> in <filename unknown>:0 
>  at GUI.AppDelegate.DidFinishLaunching (Foundation.NSNotification notification) <0x1088d6980 + 0x0008c> in <filename unknown>:0 
>  at (wrapper managed-to-native) AppKit.NSApplication:NSApplicationMain (int,string[])
>  at AppKit.NSApplication.Main (System.String[] args) <0x1088d0d50 + 0x000c3> in <filename unknown>:0 
>  at GUI.MainClass.Main (System.String[] args) <0x1005dae50 + 0x00025> in <filename unknown>:0 


## Steps to reproduce

1. Load the attached sample into Xamarin Studio

2. Launch the app in Debug configuration

Expected result: App will launch and be debuggable.

Actual result: App stops and Error noted above is output to the console as well as a dialog popup indicating that it could not connect to the debugger.

3. Launch the app in Release configuration

Expected result: App will launch.

Actual result:App stops and stack trace noted above is output to the console.


## Notes 

Removing all code related to the DLLImport statements and the link_flags in the "additional mmp arguments" resolves the issue, but of course they want to use the static library. :-)

The above error messages occur when using the "Unsupported" target framework and appear before the app appears to launch, but when switching to the Xamarin.Mac .NET 4.5 framework the app tries to launch in debug (endless bouncing dock icon) but never does. If you force quit the app then a dialog pops up saying "Could not connect to the debugger." If launched in Release with the Xamarin.Mac .NET 4.5 framework then the app crashes right away and produces the same stack trace as above.

I noted that the obsolete method `Dns.GetHostByName` was being used but switching to the recommended Dns.GetHostEntry did not affect the issue. 

As per this forum post by Brendan [1] I ran the app from the console and have attached the output files in "OutputFromTerminalRun.zip". 

[1] https://forums.xamarin.com/discussion/comment/148087/#Comment_148087


## Environment

=== Xamarin Studio ===

Version 5.10.1 (build 6)
Installation UUID: 964c531b-d928-456b-a9ae-e1f82266b360
Runtime:
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

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

=== Xamarin.Android ===

Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.0.0 (Business Edition)
Hash: 7322991
Branch: master
Build date: 2015-12-08 16:20:29-0500

=== Xamarin.Mac ===

Version: 2.4.0.109 (Business Edition)

=== Xamarin Inspector ===

Version: 0.3.2.3
Hash: 1b526e6
Branch: master
Build date: Tue Nov 17 20:54:30 UTC 2015

=== Build Information ===

Release ID: 510010006
Git revision: 0b60eecdb531933734519c13257d16a780274aab
Build date: 2015-12-04 20:28:20-05
Xamarin addins: 9876fd7c9837977178411ec7375b4352c0a0d6af
Build lane: monodevelop-lion-cycle6-baseline

=== Operating System ===

Mac OS X 10.11.2
Darwin Jons-iMac.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 3 Chris Hamons 2016-01-05 19:33:44 UTC
I am able to reproduce w/ the example. I can also reproduce by the following simple steps:

- you can make a new XM project
- link attached libUDT.a 
- run IPHostEntry ipEntry = Dns.GetHostByName(Dns.GetHostName());

However, if I use a random other static lib (such as one that has a function to add two numbers), I do not have a problem.

I don't know what is in libUDT.a, but it is obviously the source of the issue. An thus, I do not believe this is a Xamarin.Mac issue.