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

binding to an already taken address misreported #395

Closed
pplu opened this issue May 19, 2016 · 5 comments
Closed

binding to an already taken address misreported #395

pplu opened this issue May 19, 2016 · 5 comments
Labels

Comments

@pplu
Copy link

pplu commented May 19, 2016

Hi,

looks like WLS is returning EINVAL when the address/port is alredy binded to by another process

bind(4, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EINVAL (Invalid argument)

An strace on a linux kernel will return

bind(4, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE

This misguides the user, since the application returns errors pointing to "Invalid Argument":

jlmartinez@W001025:~/mojo$ ./myapp.pl daemon
Can't create listen socket: Invalid argument at /usr/share/perl5/Mojo/IOLoop.pm line 119.

instead of this more descriptive error (on Linux)

vagrant@precise64:~/mojo$ ./myapp.pl daemon
Can't create listen socket: Address already in use at /home/vagrant/mojo/local/lib/perl5/Mojo/IOLoop.pm line 127.

The program fail to start correctly, but the human that is diagnosing the error is mislead to thinking that something in the code is broken (passing invalid arguments), instead of thinking that he is simply binding to an address already in use.

To reproduce:

sudo apt-get install -y libmojolicious-perl
mkdir mojo_test
cd mojo_test
mojo generate lite_app my_test
./my_test daemon --listen http://0.0.0.0:3000 &
./my_test daemon --listen http://0.0.0.0:3000

Note: I've used Perl Mojolicious to setup the environment in a quick way, but this will probably apply to any language/framework.

@pplu
Copy link
Author

pplu commented May 19, 2016

This is probably the underlying cause of #393

@sunilmut
Copy link
Member

@pplu - Thanks for reporting the issue. The underlying cause is not #393. The bug was in the WSL socket code where it was returning EINVAL (instead of EADDRINUSE) when a socket tries to bind to a address that is already in use. The bug has been fixed sometime back in our dev branch, but hasn't made it to the release branch yet.

@pplu
Copy link
Author

pplu commented May 20, 2016

When is the next build expected? how will it be distributed / applied? I've run into a decent amount of bugs that are due to be fixed (some with workaround, like #186 (comment)), so it would be nice to know approximately when I can "retest" some stuff in WSL without workarounds.

@aseering
Copy link
Contributor

@pplu -- the official WSL folks have been quiet about this in the past; new builds include work from all of Windows, not just WSL, so maybe they just don't know?

But there seems to be a new build roughly every week to two weeks, give or take.

Fast-Ring builds are distributed through Windows Update. No other distribution channel is currently available; you just have to wait until Windows Update pops up saying that an update is available.

It can take a day or two for updates to roll out to all Windows users. Also, the update process seems to be somewhat fragile; sometimes computers just don't receive updates, in which case most likely some state on (probably) your machine or (less likely) your Microsoft account has gotten corrupt in some funny way. If you search around online, you'll find lots of forum posts of people hitting this problem, and a variety of solutions each of which helped someone and didn't help someone else. Reinstalling Windows seems to be reasonably reliable, if extreme.

Note that there are .iso images available for the Windows Slow Ring through the Insider website. WSL has not yet reached the Slow Ring. But if you do have to reinstall for some reason, you can install the latest Slow Ring build and then switch to the Fast Ring to get just the most-recent few builds.

@russalex
Copy link
Contributor

russalex commented Jun 9, 2016

@sunilmut's fix is in build 14361.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants