nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.4k stars 28.99k forks source link

Assertion failed: (!"unknown EAI_* error code"), function uv__getaddrinfo_translate_error, file src/unix/getaddrinfo.c, line 90. #51262

Open BenoitMercier opened 8 months ago

BenoitMercier commented 8 months ago

Version

16.18.1

Platform

FreeBSD eisy 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 #9 releng/13.2-n254638-d20ece445acf-dirty: Fri Oct 20 16:50:52 UTC 2023 root@bsdev.isy.io:/usr/obj/usr/src/amd64.amd64/sys/eisy amd64

Subsystem

https://github.com/nodejs/node/blob/main/deps/uv/src/unix/getaddrinfo.c

What steps will reproduce the bug?

node.js crashes randomly with this error. We can not find any way to reproduce it.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

node.js crashes randomly with this error: Assertion failed: (!"unknown EAI_* error code"), function uv__getaddrinfo_translate_error, file src/unix/getaddrinfo.c, line 90.

Additional information

I believe the error would be caused by a EAI_MAX error

FreeBSD glibc's getaddrinfo() can return a EAI_MAX error, which is not trapped by libuv uv__getaddrinfo_translate_error()

Ref: getaddrinfo man page says it can return errors from gai_strerror(3) Freebsd man page: https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3 gai_strerror(3): https://man.freebsd.org/cgi/man.cgi?query=gai_strerror&sektion=3&manpath=FreeBSD+13.2- RELEASE+and+Ports

When googling around, I can find a reference to EAI_MAX error in netdb.h. Ref: https://gitea-dev.freebsd.org/FreeBSD/src/src/tag/release/13.1.0/include/netdb.h

In node.js' uv__getaddrinfo_translate_error(), there is a case for all errors, except EAI_MAX That's the case for node.js 16.18.1 which we are using, but also the main branch too.

Ref: https://github.com/nodejs/node/blob/main/deps/uv/src/unix/getaddrinfo.c

Therefore, we probably need to add:

if defined(EAI_MAX)

case EAI_MAX: return UV_EAI_MAX;

endif

And of course UV_EAI_MAX would need to be defined.

marco-ippolito commented 8 months ago

cc @nodejs/libuv

santigimeno commented 8 months ago

@BenoitMercier thanks for the report. Can you confirm that the error is actually EAI_MAX or is it just a guess? If the latter, can you add a printf in uv__getaddrinfo_translate_error() so we can actually know the error?

saghul commented 8 months ago

Looks like we should have that mapping in libuv indeed.

BenoitMercier commented 8 months ago

@santigimeno

@BenoitMercier thanks for the report. Can you confirm that the error is actually EAI_MAX or is it just a guess? If the latter, can you add a printf in uv__getaddrinfo_translate_error() so we can actually know the error?

I have no clue how to compile. I just identified EAI_MAX as the only possibility looking at uv__getaddrinfo_translate_error() and netdb.h