Boost logo

Boost Users :

From: Nils Frielinghaus (nils.frielinghaus_at_[hidden])
Date: 2021-08-24 12:57:33



> Can you please post a small, self-contained program that reproduces the segfault?

I understand that it would be very desirable to have a small self-contained program reproducing it, but I am struggling a bit to provide this, as the issue occurs in the interaction with the OS and the DNS.
I am currently unsure on how to wrap this into a simple reproducer.
My test program looks something like this, with the DNS having an incorrect entry for "incorrectdnsentry.test.net" mapping to "dnsentry.test.net/" (the slash is not legal here):
This set-up will produce a segfault on a Yocto-based Linux distribution.

#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char* argv[])
{

  try
  {
    boost::asio::io_service io_service;
    boost::asio::ip::tcp::resolver resolver(io_service);
    boost::asio::ip::tcp::resolver::query query("incorrectdnsentry.test.net", "80");
    boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query);
    std::cout << "Host name was resolved to: " << iter->endpoint() << std::endl;
  }
  catch (const std::exception&)
  {
    std::cout << "Host name could not be resolved" << std::endl;
  }
}

What can be easily demonstrated though, is, that the translate_addrinfo_error function converts EAI_SYSTEM with errno=0 (which is triggered by the above set-up) into a Boost error code that shows success.
So this program will output "Success".

int main(int argc, char* argv[])
{
  auto ec = boost::asio::detail::socket_ops::translate_addrinfo_error(EAI_SYSTEM);
  std::cout << "Error message: " << ec.message() << std::endl;
}

Kind regards,
  Nils


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net