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

Inconsistent error handling on different platforms #306

Closed
squeek502 opened this issue Sep 5, 2018 · 0 comments
Closed

Inconsistent error handling on different platforms #306

squeek502 opened this issue Sep 5, 2018 · 0 comments

Comments

@squeek502
Copy link
Member

squeek502 commented Sep 5, 2018

Luv currently assumes all Libuv functions only return negative error codes, but that is not always true. On Windows, Libuv does not always translate its error codes before returning them, meaning that it sometimes returns positive error codes.

One example to illustrate the issue:

local uv = require('uv')

local socket = uv.new_udp()
assert(uv.udp_bind(socket, "0.0.0.0", 8002))

assert(uv.udp_recv_start(socket, function(err, data, addr, flags)
  print(err, data)
end))

-- this assert fails on Linux, but succeeds on Windows
assert(uv.udp_recv_start(socket, function(err, data, addr, flags)
  print(err, data)
end))

This doesn't seem to be an isolated or rare case, either; there are many places where Libuv returns GetLastError()/WSAGetLastError() directly. Nevermind, this looks like a Libuv bug; other functions that return untranslated error codes are internal Libuv functions that have their errors translated elsewhere.

EDIT: Reported to Libuv: libuv/libuv#1978

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

No branches or pull requests

1 participant