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

possible libuv issue with macos 10.15: empty udp message not registering #30030

Closed
daviehh opened this issue Oct 18, 2019 · 24 comments
Closed

possible libuv issue with macos 10.15: empty udp message not registering #30030

daviehh opened this issue Oct 18, 2019 · 24 comments
Labels
confirmed-bug Issues with confirmed bugs. dgram Issues and PRs related to the dgram subsystem / UDP. macos Issues and PRs related to the macOS platform / OSX.

Comments

@daviehh
Copy link

daviehh commented Oct 18, 2019

  • Version:
    v12.12.0
  • Platform:
    macos catalina/10.15 (19A602)
  • Subsystem:
    n/a

When sending an empty udp message, the message will not be received until another non-empty udp message is received.

Example/Reproduce: (may only affect macos 10.15?)

file server.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');
var server = dgram.createSocket('udp4');

server.on('listening', function() {
  var address = server.address();
 console.log('UDP Server listening on ' + address.address + ':' + address.port);
});

server.on('message', function(message, remote) {
 console.log(remote.address + ':' + remote.port +' - ' + message);
});

server.bind(PORT, HOST);

file client_test.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');


var client = dgram.createSocket('udp4');
var message = Buffer.from('abc');

client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {
  if (err) throw err;
  console.log('UDP message sent to ' + HOST +':'+ PORT);
  client.close();
});

file client_0.js

var PORT = 33333;
var HOST = '127.0.0.1';

var dgram = require('dgram');


var client = dgram.createSocket('udp4');
var message = Buffer.from('');

client.send(message, 0, message.length, PORT, HOST, function(err, bytes) {
  if (err) throw err;
  console.log('UDP message sent to ' + HOST +':'+ PORT);
  client.close();
});

run the server code, then run the client_0.js: no response in server.
followed by running client_test.js: server got empty and the "abc" message.

@addaleax addaleax added the dgram Issues and PRs related to the dgram subsystem / UDP. label Oct 18, 2019
@addaleax
Copy link
Member

Does this also happen with Node 12.11.1?

@daviehh
Copy link
Author

daviehh commented Oct 18, 2019

@addaleax Yes, just tried with the binary using https://nodejs.org/dist/v12.11.1/

@addaleax addaleax added the macos Issues and PRs related to the macOS platform / OSX. label Oct 18, 2019
@addaleax
Copy link
Member

/cc @nodejs/platform-macos

@daviehh Have you tried recreating this with e.g. Python? I’m not on a mac but I have the suspicion that this may actually be just a platform quirk of macOS that we can’t do anything about.

@daviehh
Copy link
Author

daviehh commented Oct 18, 2019

@addaleax I have actually tried Python, empty udp message works there:

receiving:

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("127.0.0.1", 6000))

while True:
    data, addr = sock.recvfrom(1024)
    print("received message:", data)

sending:

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b"", ("127.0.0.1", 6000))

@lpinca
Copy link
Member

lpinca commented Oct 20, 2019

It seems our test suite also fails due to this on macOS Catalina.

=== release test-dgram-connect-send-empty-buffer ===                          
Path: parallel/test-dgram-connect-send-empty-buffer
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-buffer.js
--- TIMEOUT ---
=== release test-dgram-connect-send-empty-array ===        
Path: parallel/test-dgram-connect-send-empty-array
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-array.js
--- TIMEOUT ---
=== release test-dgram-connect-send-empty-packet ===       
Path: parallel/test-dgram-connect-send-empty-packet
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-connect-send-empty-packet.js
--- TIMEOUT ---
=== release test-dgram-send-empty-array ===                
Path: parallel/test-dgram-send-empty-array
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-array.js
--- TIMEOUT ---
=== release test-dgram-send-empty-buffer ===               
Path: parallel/test-dgram-send-empty-buffer
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-buffer.js
--- TIMEOUT ---
=== release test-dgram-send-empty-packet ===
Path: parallel/test-dgram-send-empty-packet
Command: out/Release/node /Users/luigi/code/node/test/parallel/test-dgram-send-empty-packet.js
--- TIMEOUT ---
[03:46|% 100|+ 2791|-   6]: Done

@lpinca lpinca added the confirmed-bug Issues with confirmed bugs. label Oct 20, 2019
@daviehh
Copy link
Author

daviehh commented Oct 20, 2019

Thanks! I first noticed this issue with a beta version of another language that uses libuv (julia), so it's likely that it's a libuv bug; is it good for the bug report to be here or is it better to report to libuv? Not sure how to write a simple c code that directly uses libuv to reproduce the issue though.

@santigimeno
Copy link
Member

Yeah, I've reproduced the issue in libuv. Apparently the message is actually sent (I've checked it with tcpdump) but not received.

@santigimeno
Copy link
Member

It looks like a problem with kqueue not reporting the event. The python example does not seem to apply to our case as it's waiting on recvfrom syscall.

@addaleax
Copy link
Member

@nodejs/libuv Has anybody reported this to Apple yet? I’m assuming that that’s the thing to do here, no?

@bnoordhuis
Copy link
Member

Yes... except sending a bug report to Apple is like throwing matter into a black hole: it disappears and is never seen again.

@indutny
Copy link
Member

indutny commented Dec 17, 2019

I have a channel to get some additional information from Apple given the bug report number. Has anyone reported it?

@indutny
Copy link
Member

indutny commented Dec 17, 2019

Oh... I just realized that I might have reported this in 2014 and provided a fix. Here is a repo (by other person) that reproduces the issue using outdated libuv version: https://github.com/misterdjules/udp-empty-dgram-repro

@indutny
Copy link
Member

indutny commented Dec 17, 2019

Here goes the original report: nodejs/node-v0.x-archive#8023

@Keno
Copy link

Keno commented Dec 21, 2019

So this just regressed then? If nobody has reported a new radar, I'm happy to do that.

@Keno
Copy link

Keno commented Dec 22, 2019

Looks like Apple retired radar, but I've filed this using the new system as FB7503750.

kleimkuhler added a commit to kleimkuhler/mio that referenced this issue Jan 21, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
kleimkuhler added a commit to kleimkuhler/mio that referenced this issue Jan 21, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
sam-github added a commit to sam-github/node that referenced this issue Feb 24, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: nodejs#30030
Refs: nodejs/build#2189 (comment)
sam-github added a commit that referenced this issue Feb 26, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: #30030
Refs: nodejs/build#2189 (comment)

PR-URL: #31936
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@sam-github
Copy link
Contributor

IMO, I suggest our tests should be reworked to not require platforms support zero-length UDP datagrams, and instead check they either work, or not throw js/c++ errors because our code is broken.

For platforms that do support them, its nice that node and libuv do, as well, but its not exactly a critical feature. I'm not aware of any actual uses for zero-length UDP other than port-knocking during network intrusion or crashing unsuspecting UDP listeners, who insufficiently validate the received packet sizes.

Making the tests auto-detect what is happening, and pass whether or not the packets are received seems like a long-term robust solution, and will get OS X 10.15 out of perma-yellow.

Thoughts?

cc: @AshCripps

@AshCripps
Copy link
Member

@sam-github You could work the tests to do that however, from what I understand the test is supposed to pass on mac, apple just introduced a regression in catlina rather than the feature not being supported.

BethGriggs pushed a commit that referenced this issue Feb 27, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: #30030
Refs: nodejs/build#2189 (comment)

PR-URL: #31936
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
codebytere pushed a commit that referenced this issue Feb 27, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: #30030
Refs: nodejs/build#2189 (comment)

PR-URL: #31936
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@AshCripps
Copy link
Member

@sam-github Turns out these tests used to be skipped fully on apple in the first place when the bug first appeared in macos 10.9. This would get the CI out of perma yellow but would need to be swapped back if apple ever fix it. Im going to try and see if I can find out the progress of the apple bug report and see if anythings being done about it tomorrow.

#22546 (Can only find the PR to remove the skip)

@Keno
Copy link

Keno commented Mar 4, 2020

Apple has told me that they have identified a fix and will ship it in a future OS update, but have not provided any further details than that.

@AshCripps
Copy link
Member

@Keno At least that something, thanks for letting us know!

@richardlau
Copy link
Member

#22546 (Can only find the PR to remove the skip)

The skip is very old and was added in the old repository (see #30030 (comment)).

puzpuzpuz pushed a commit to puzpuzpuz/node that referenced this issue Mar 8, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: nodejs#30030
Refs: nodejs/build#2189 (comment)

PR-URL: nodejs#31936
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
@MylesBorins
Copy link
Contributor

MylesBorins commented Mar 11, 2020

I'm seeing multiple instances of our test suite not respecting the mark of flaky in these tests, any idea what's up?

https://ci.nodejs.org/job/node-test-commit-osx/32536/#showFailuresLink

nvm failure is due to test-timers-blocking-callback

codebytere pushed a commit that referenced this issue Mar 14, 2020
They fail on OS X 10.15 (aka "Catalina"), but pass on earlier OS X.

Refs: #30030
Refs: nodejs/build#2189 (comment)

PR-URL: #31936
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>

PR-URL: #32146
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
@lpinca
Copy link
Member

lpinca commented Mar 25, 2020

The issue seems to be fixed in macOS 10.15.4

kleimkuhler added a commit to kleimkuhler/mio that referenced this issue Mar 27, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
kleimkuhler added a commit to kleimkuhler/mio that referenced this issue Mar 27, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
kleimkuhler added a commit to kleimkuhler/mio that referenced this issue Mar 27, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Thomasdezeeuw pushed a commit to Thomasdezeeuw/mio that referenced this issue Nov 6, 2020
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Thomasdezeeuw pushed a commit to Thomasdezeeuw/mio that referenced this issue Nov 6, 2020
Other discussion: nodejs/node#30030

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Thomasdezeeuw pushed a commit to Thomasdezeeuw/mio that referenced this issue Nov 6, 2020
Other discussion: nodejs/node#30030

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Thomasdezeeuw pushed a commit to tokio-rs/mio that referenced this issue Nov 13, 2020
Other discussion: nodejs/node#30030

Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
@BethGriggs
Copy link
Member

Closing as based on the comments this is fixed, and the tests are no longer skipped in CI on macOS.

staltz pushed a commit to nodejs-mobile/nodejs-mobile that referenced this issue Nov 22, 2022
macOS 10.15 Catalina and iOS 13 have a bug which causes empty UPD
packets not to work. This seems to be a regression for a bug that
affected macOS 10.10.

Ref: nodejs/node#30030
staltz pushed a commit to nodejs-mobile/nodejs-mobile that referenced this issue Nov 29, 2022
macOS 10.15 Catalina and iOS 13 have a bug which causes empty UPD
packets not to work. This seems to be a regression for a bug that
affected macOS 10.10.

Ref: nodejs/node#30030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. dgram Issues and PRs related to the dgram subsystem / UDP. macos Issues and PRs related to the macOS platform / OSX.
Projects
None yet
Development

No branches or pull requests