Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Empty UDP datagrams tests broken #8023

Closed
misterdjules opened this issue Jul 30, 2014 · 14 comments
Closed

Empty UDP datagrams tests broken #8023

misterdjules opened this issue Jul 30, 2014 · 14 comments
Assignees

Comments

@misterdjules
Copy link

This PR added support for receiving zero-length UDP datagrams. However, It seems that empty UDP datagrams cannot be received on MacOS X with libuv.

As a result, test/simple/test-dgram-send-empty-buffer.js and test/simple/test-dgram-empty-packet.js fail on MacOS X. See jenkin's reports here and here.

I created a repository with a minimal repro of the issue in plain C/libuv . You can have a look at the README to know how to reproduce the issue. This shows that the issue seems to be in libuv itself, or at a lower level.

I haven't had the time to investigate more, but any help is more than welcome!

@trevnorris
Copy link

@indutny Sorry, assigning to you. I don't have an OSX machine I can test this on.

@indutny
Copy link
Member

indutny commented Jul 31, 2014

Thank you, I just reproduced it with your scripts! Right now I can confirm that it sends 0-length UDP packet. Trying to figure out why there is no notification after that.

@indutny
Copy link
Member

indutny commented Jul 31, 2014

Surprisingly, the same thing works on FreeBSD so this is not because of the watermark... Or FreeBSD has fixed their kqueue implementation.

@misterdjules
Copy link
Author

@indutny Did you have some time to investigate more? If so, what did you find out? I may have some time to investigate more during the week-end, but I want to complete a first pass over all failing tests on jenkin's nodejs-master first before digging deeper into this one.

@indutny
Copy link
Member

indutny commented Aug 1, 2014

I believe that OSX has uncofigurable low-watermark on UDP sockets. Right now I'm trying to find some flag or some way to get notification. But it seems very unlikely that there is a way to make it work the same way as it does on other Unixes.

@misterdjules
Copy link
Author

@indutny Ok. Have you tried using setsockopt with SO_RCVLOWAT set to 0?

@indutny
Copy link
Member

indutny commented Aug 1, 2014

Certainly, it returns EINVAL, I also tried NOTE_LOWAT, but it is ignored if it is less than SO_RCVLOWAT.

@indutny
Copy link
Member

indutny commented Aug 2, 2014

Here is a simplified test: https://github.com/indutny/0-udp

@indutny
Copy link
Member

indutny commented Aug 2, 2014

@misterdjules I believe this is an OSX bug. I have just reported it (# 17894467 ) and submitted a patch. However, it seems that it is working fine in other BSDs only because of some sort of luck :) I'm in the middle of discussing it with FreeBSD people, so I don't have much more details right now.

I guess all that we can do right now - is making this test platform specific. So here is a commit: 47a103a

@indutny indutny closed this as completed Aug 2, 2014
indutny added a commit that referenced this issue Aug 2, 2014
@misterdjules
Copy link
Author

@indutny My concern with only making the test platform specific is that developers will expect sending empty datagrams to work on OS X as it works on other platforms. I would suggest:

  1. Making sending empty UDP datagrams on OS X throw so that developers don't expect it to work.
  2. Updating the test so that we make sure it throws on OS X.

If your patch get merged upstream later, then we can remove the throw on OS X and update the tests.

What do you think?

@indutny
Copy link
Member

indutny commented Aug 4, 2014

Well... in fact, it works. Even more, you can receive them. They just don't trigger any events, so you'll need to wait for a consequent UDP packet to receive every of them.

@indutny
Copy link
Member

indutny commented Aug 4, 2014

Not sure if throwing would be helpful if you are communicating with other server.

@misterdjules
Copy link
Author

@indutny Ok, I thought it was consistently throwing before #7885, but it was only throwing in the case of sending an empty buffer, not an empty datagram (passing a buffer with non-zero length to send but 0 as the length argument).

@indutny
Copy link
Member

indutny commented Oct 2, 2015

Hooray! This one is fixed in El Capitan ;)

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

No branches or pull requests

3 participants