nodejs/node · critical
ares_library_init: %s
Error message
ares_library_init: %s
What it means
Printed by adig's main() at adig.c:1497 when ares_library_init(ARES_LIB_INIT_ALL) returns a status other than ARES_SUCCESS. This call initializes the c-ares library's global state (including WinSock startup on Windows). The error string from ares_strerror() is included. The tool returns 1 immediately — no channel is created, no queries are issued.
Source
Thrown at deps/cares/src/tools/adig.c:1497
global_config.options.ndomains = 1;
}
}
int main(int argc, char **argv)
{
ares_channel_t *channel = NULL;
ares_status_t status;
int rv = 0;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
WSADATA wsaData;
WSAStartup(wVersionRequested, &wsaData);
#endif
status = (ares_status_t)ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS) {
fprintf(stderr, "ares_library_init: %s\n", ares_strerror((int)status));
return 1;
}
config_defaults();
if (!read_cmdline(argc, (const char * const *)argv, 1)) {
printf("\n** ERROR: %s\n\n", global_config.error);
print_help();
rv = 1;
goto done;
}
if (global_config.no_rcfile && !read_rcfile()) {
fprintf(stderr, "\n** ERROR: %s\n", global_config.error);
}
if (global_config.is_help) {
print_help();View on GitHub (pinned to 1b2de5e052)
Solutions
- Check the ares_strerror() output in the message to identify the specific failure code (e.g., ARES_EFORMERR for internal format errors).
- On Windows, verify that WSAStartup succeeded — check the USE_WINSOCK version constant matches the installed WinSock.
- Ensure ares_library_init is called exactly once per process (or use reference counting) and matched with ares_library_cleanup.
- Rebuild adig and c-ares from the same source version to avoid ABI mismatches.
Example fix
// before: double-init or version mismatch
ares_library_init(ARES_LIB_INIT_ALL); // first call (e.g., in another lib)
// adig's main() calls ares_library_init again
// -> 'ares_library_init: ...'
// after: init once, cleanup once
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS) { /* handle */ }
// ... use c-ares ...
ares_library_cleanup(); // exactly once at shutdown Defensive patterns
Strategy: validation
Validate before calling
// Call ares_library_init exactly once per process
static int lib_initialized = 0;
if (!lib_initialized) {
ares_status_t status = (ares_status_t)ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS) {
fprintf(stderr, "init failed: %s\n", ares_strerror((int)status));
return -1;
}
lib_initialized = 1;
}
// at process exit: ares_library_cleanup(); Try / catch
ares_status_t status = (ares_status_t)ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS) {
fprintf(stderr, "ares_library_init: %s\n", ares_strerror((int)status));
// do not proceed to channel creation; exit or fall back
return EXIT_FAILURE;
} Prevention
- Initialize c-ares exactly once per process and clean up exactly once at exit.
- Match c-ares header version with the linked shared library.
- On Windows, verify WSAStartup succeeds before calling ares_library_init.
When it happens
Trigger: Calling ares_library_init(ARES_LIB_INIT_ALL) at the start of adig's main() (line 1496). Fails when the library cannot initialize its internal subsystems — on Windows if WSAStartup failed earlier (line 1488), or if the library was compiled without required features. Also fails if ares_library_init has already been called without a matching ares_library_cleanup (double-init).
Common situations: On Windows, WSAStartup fails due to a WinSock version mismatch or resource limitation. The c-ares shared library version is incompatible with the headers the tool was compiled against. The library was built with ARES_LIB_INIT_ALL but the platform lacks a required init component. Another part of the application already called ares_library_init.
Related errors
- ares_library_init: %s
- select fail: %d
- ** ERROR: %s
- ares_init_options: %s
- ares_set_servers_ports_csv: %s: %s
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/e60bfe416547036e.
Report an issue: GitHub.