Bug 20801 - Runtime/debugger hang with xsp on windows
Summary: Runtime/debugger hang with xsp on windows
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-06-22 18:27 UTC by pinggi
Modified: 2017-07-12 22:48 UTC (History)
4 users (show)

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

What happens after running the asp.net web app from XS in debug mode (48.15 KB, image/png)
2014-06-24 12:44 UTC, pinggi
XS project runtime (33.68 KB, image/png)
2014-06-25 12:45 UTC, pinggi

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 GitHub or Developer Community 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:

Description pinggi 2014-06-22 18:27:38 UTC
When I trz to run ASP.NET MVC project (CTRL+F5) it ends up with:

Adding applications '/:.'...
Registering application:
    Host:          any
    Port:          any
    Virtual path:  /
    Physical path: C:\Web\MVCTest\MVCTest
Listening on address:
Root directory: C:\Web\MVCTest\MVCTest
Error: System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.

  at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00065] in C:\cygwin\sources\mono\mcs\class\System\System.Net.Sockets\Socket.cs:1115 
  at Mono.WebServer.XSPWebSource.CreateSocket () [0x00013] in /tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer.XSP/XSPWebSource.cs:104 
  at Mono.WebServer.ApplicationServer.Start (Boolean bgThread) [0x00077] in /tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer/ApplicationServer.cs:326 
  at Mono.WebServer.ApplicationServer.Start (Boolean bgThread, System.Exception initialException) [0x00007] in /tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer/ApplicationServer.cs:306 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer:Start (bool,System.Exception)
  at Mono.WebServer.XSP.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00737] in /tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer.XSP/main.cs:467 
The application exited with code: 1

I need to go to Project options->XSP Web Server and change port number to different one. After some time I end up with several mono.exe processes (most likely XSP4 processes that run and block the ports). I need to kill them in order to free the ports. 

Why there is no automatic ending of the running web app?
Comment 1 Mikayla Hutchinson [MSFT] 2014-06-22 20:23:18 UTC
There is. When you hit "stop", we kill the running xsp instance. This works fine for me with the .NET runtime. Does this only happen with the Mono runtime?  Do you have a native debugger you could use to inspect the hung Mono processes?
Comment 2 pinggi 2014-06-23 14:23:24 UTC
It happens when I run the web app in debug mode (F5) but actually the debugger doesn't start and nothing happens even the button has changed from 'play' to 'stop'. Then I stop debugging mode by pressing the 'stop' button and the mono.exe process stays running.

Command line of the process is:

"C:\PROGRA~2\MONO-3~2.3\bin\mono.exe"   "C:\PROGRA~2\MONO-3~2.3\lib\mono\4.0\winhack\xsp4.exe" --port 80 --address --nonstop --verbose --nonstop

So it looks like it doesn't hang but lost the handle. It might be connected with previously reported bug 20801.
Comment 3 pinggi 2014-06-23 14:35:04 UTC
Sorry, previously reported bug is 20800.
Why here is not possible to edit the posts?

So I think the debugging basically doesn't work and it causes that XS doesn't stop running xsp4.exe. I mean by "doesn't work' that it doesn't run the debugger, doesn't stop on break points, doesn't show page in the browser. Only an empty application output window is shown and the play button is changed to stop button. After stopping it, basically nothing happen. It hides the output window and get back to normal state leaving the process running.
Comment 4 Mikayla Hutchinson [MSFT] 2014-06-23 15:36:44 UTC
If the mono process stays running when we try to end it, that sounds like a runtime bug.
Comment 5 Mikayla Hutchinson [MSFT] 2014-06-23 15:37:33 UTC
FWIW, Mono on Windows isn't well supported, I suggest you use .NET.
Comment 6 pinggi 2014-06-24 12:28:34 UTC
What do you mean by that? Shouldn't I use Xamarin Studio?

I use Microsoft.NET runtime in XS. I have it selected:

Tools->Options->.NET Runtimes->Microsoft .NET (Default)

When I try to debug the web app (pressing F5), it executes cmd line I've sent in the post from 2014-06-23 14:23:24 and stays running. 

Only way I can work is to kill the mono.exe process and continue developing and running the web app without debug (ctrl+F5). if the xsp is running in that case it shows me a dialog saying "An application is already running. Do you want to stop it?". And I need to click the 'Stop' button again and again, but it is the another story.
Comment 7 pinggi 2014-06-24 12:44:44 UTC
Created attachment 7165 [details]
What happens after running the asp.net web app from XS in debug mode
Comment 8 pinggi 2014-06-24 12:48:12 UTC
I added screenshot showing what happens when I press F5 in XS (=executing asp.net web app in debug mode).

My comment is placed directly in the picture. When I stop debug mode, the mono.exe process is still running. I am not able to run the web app again without debug mode because the mono.exe (xsp4) block the port, so I would end up with the message I've sent in the first post.

Hope now it is understandable.
Comment 9 Mikayla Hutchinson [MSFT] 2014-06-24 18:10:56 UTC
That's definitely using the Mono runtime, not the .NET runtime. Check the Project-> Active Runtime menu, maybe you've set a different runtime for the project
Comment 10 pinggi 2014-06-25 12:45:05 UTC
Created attachment 7180 [details]
XS project runtime

It is really .Net Runtime. Check the enclosed picture.
Comment 11 Ludovic Henry 2017-07-12 22:48:16 UTC
Can you still reproduce that with latest version of mono? If you still can, please reopen and provide a repro case. Thank you