{"record":{"id":"9a7928fce26ebc26","repo":"nodejs/node","slug":"ares-init-options-s","errorCode":null,"errorMessage":"ares_init_options: %s\n","messagePattern":"ares_init_options: (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"deps/cares/src/tools/adig.c","lineNumber":1531,"sourceCode":"\n  if (global_config.is_help) {\n    print_help();\n    goto done;\n  }\n\n  if (global_config.name == NULL) {\n    printf(\"missing query name\\n\");\n    print_help();\n    rv = 1;\n    goto done;\n  }\n\n  config_opts();\n\n  status = (ares_status_t)ares_init_options(&channel, &global_config.options,\n                                            global_config.optmask);\n  if (status != ARES_SUCCESS) {\n    fprintf(stderr, \"ares_init_options: %s\\n\", ares_strerror((int)status));\n    rv = 1;\n    goto done;\n  }\n\n  if (global_config.servers) {\n    status =\n      (ares_status_t)ares_set_servers_ports_csv(channel, global_config.servers);\n    if (status != ARES_SUCCESS) {\n      fprintf(stderr, \"ares_set_servers_ports_csv: %s: %s\\n\",\n              ares_strerror((int)status), global_config.servers);\n      rv = 1;\n      goto done;\n    }\n  }\n\n  /* Debug */\n  if (global_config.opts.display_command) {\n    printf(\"\\n; <<>> c-ares DiG %s <<>>\", ares_version(NULL));","sourceCodeStart":1513,"sourceCodeEnd":1549,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/cares/src/tools/adig.c#L1513-L1549","documentation":"Printed by adig's main() at adig.c:1531 when ares_init_options() fails to create a DNS resolver channel. The function receives &channel, &global_config.options, and global_config.optmask — the configured options from command-line and rcfile parsing. The ares_strerror() detail identifies the specific failure. The tool sets rv=1 and jumps to cleanup, destroying any partially-created channel.","triggerScenarios":"Calling ares_init_options() at line 1529 after config_opts() has populated global_config.options and optmask. Fails when the options are internally inconsistent — e.g., an invalid socket send buffer size, a malformed domain list, an invalid timeout value, or the system lacks resources to create the internal sockets and channels.","commonSituations":"An adig configuration file (~/.adigrc or similar) contains malformed values. Command-line options override defaults with out-of-range values. The system is out of memory or file descriptors. A bitmask in optmask references options that were not properly initialized in the options struct.","solutions":["Check the ares_strerror() output for the specific failure code.","Simplify the options: run adig with minimal flags (no -s, no custom timeouts) to isolate which option causes the failure.","If using an rcfile, validate its contents or bypass it with --no-rcfile.","Ensure optmask bits match fields actually set in the ares_options struct — mismatched bits cause init failures."],"exampleFix":"// before: malformed options cause init failure\nadig --timeout=-1 example.com\n// -> 'ares_init_options: ...'\n\n// after: use valid option values\nadig --timeout=5 example.com","handlingStrategy":"validation","validationCode":"// Before calling ares_init_options, validate option fields\nif (options.timeout_ms == 0 && (optmask & ARES_OPT_TIMEOUT)) {\n    fprintf(stderr, \"invalid timeout\\n\");\n    return -1;\n}\n// Ensure optmask bits correspond to initialized fields in options struct","typeGuard":null,"tryCatchPattern":"status = (ares_status_t)ares_init_options(&channel, &options, optmask);\nif (status != ARES_SUCCESS) {\n    fprintf(stderr, \"ares_init_options: %s\\n\", ares_strerror((int)status));\n    // simplify options and retry, or fall back to ares_init()\n    status = (ares_status_t)ares_init(&channel);\n}","preventionTips":["Zero-initialize the ares_options struct before setting fields.","Only set optmask bits for fields you have explicitly configured.","Use --no-rcfile to isolate whether an rcfile is causing the issue."],"tags":["c-ares","adig","channel-init","configuration","ares-init"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}