You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
This means that Windows, the following code will run without an error, while on other platforms, it will error with EALREADY: connection already in progress:
localuv=require('uv')
localsocket=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 Windowsassert(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.
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:
uv_udp_recv_start
a second time on the same socket, Libuv will returnWSAEALREADY
in its Windows implementation, which is the positive integer10037
.uv_translate_sys_error
, so when Luv checks for errors inluv_udp_recv_start
, this positive error code is ignoredEALREADY: connection already in progress
:This doesn't seem to be an isolated or rare case, either; there are many places where Libuv returnsNevermind, this looks like a Libuv bug; other functions that return untranslated error codes are internal Libuv functions that have their errors translated elsewhere.GetLastError()
/WSAGetLastError()
directly.EDIT: Reported to Libuv: libuv/libuv#1978
The text was updated successfully, but these errors were encountered: