Skip to content

Unhandled exception #696

Open
Open

Description

@rhegner

Since I cannot build version 0.12 with VS2015, I tried the latest version in the 0.13-release branch (6a7e92c).

I can build this version successfully (with VS2015, Boost 1.62.0, OpenSsl 1.0.2j) but when I try this simple code I get an unhandled exception in the last line of the try-block where I try to access the body.

boost::network::http::client client_;
try
{

    boost::network::http::client::request request_("http://127.0.0.1:8000/");
    request_ << boost::network::header("Connection", "close");
    boost::network::http::client::response response_ = client_.get(request_);
    std::string body_ = body(response_);
}
catch (const std::exception& ex)
{
    std::string message = ex.what();
}

The error message is: "Unhandled exception at 0x75BDC54F in Test.exe: Microsoft C++ exception: boost::exception_detail::clone_implstd::exception_ptr at memory location 0x002CFC40."

Activity

  1. deanberris commented on Oct 12, 2016

    @deanberris
    Member

    I'll assume that you have a server running on the IPv4 address 127.0.0.1:8000. If you try with an IPv6 address instead ([::1]:8000) and still get the error, then I don't know and might need to get a bit more detailed debugging information.

    If you don't get the error by connecting to an IPv6 address, then I suspect this is because of a bug with address resolution potentially failing and causing an exception to be thrown in the background thread. You should actually be able to reach into the boost exception pointer to get the actual wrapped exception to see what the thrown error is.

    I would think this is address resolution, or something to do with the actual HTTP handling.

    At this point I would think this is working as intended, because the error was propagated as an exception and is something that you should be able to handle and recover from. Documentation on Boost.Exception should help with finding out what the exact exception is.

  2. rhegner commented on Oct 12, 2016

    @rhegner
    Author

    Thank you for your response!
    I get the same exception with the IPv6 address.

    The problem is that it is an unhandled exception. I don't end up in my catch block but instead the debugger breaks. So I don't see how I could handle and recover from this exception.

    Here you can see the call stack at the time when the debugger breaks. And these are the locals at the current position of the call stack.

  3. anonimal commented on Oct 12, 2016

    @anonimal

    This issue reminds me of something similar in terms of not catching the exception. This related function is the only place where we use cpp-netlib for http handling (similar to the above sample).

    Catching the calling block also has no effect.

  4. added this to the 0.13 milestone on Oct 14, 2016
  5. self-assigned this
    on Oct 14, 2016
  6. LuminousCopper commented on Oct 21, 2016

    @LuminousCopper

    I think I'm running into something similar. I finally tracked it down to a std::exception_ptr being thrown directly. I had to do the following to get the true exception, which turned out to be an ssl system error. This is using the 0.13 branch.

        try
        {
            try
            {
                net::http::client::request request("https://www.google.com/");
                request << net::header("Connection", "close");
                net::http::client client;
                net::http::client::response response = client.get(request);
                std::string body = net::http::body(response);
                std::cout << body;
            }
            catch (const std::exception_ptr& ex)
            {
                // For some reason, the http code is throwing an exception_ptr,
                // which needs to be re-thrown to get the true exception.
                std::rethrow_exception(ex);
            }
        }
        catch (const boost::system::system_error& ex)
        {
            std::cerr << "ERROR: " << boost::diagnostic_information(ex) << std::endl;
            return ex.code().value();
        }
  7. anonimal commented on Nov 13, 2016

    @anonimal

    @LuminousCopper great "catch" 😆

    This is also an issue on Win32/64 for Kovri (also built against 0.13-release) when building on MSYS2/MinGW.

    Details (along with newly caught exception messages) in monero-project/kovri#453 apply to the patch presented above (as seen in monero-project/kovri#454).

    Current clearnet HTTPS implementation here.

  8. anonimal commented on Dec 7, 2016

    @anonimal

    As just now opened in monero-project/kovri#490, this issue may also arise when connecting to servers with expired certificates. Can anyone else confirm?

    Edit: JFTR, the exception:

    ERR   HTTP: caught exception_ptr, rethrowing exception
    ERR   HTTP: Dynamic exception type: boost::system::system_error
    std::exception::what: certificate verify failed
    
  9. anonimal commented on Dec 8, 2016

    @anonimal

    As noted in monero-project/kovri#453 (comment), this issue also arose recently in arm64 (Linaro/Debian Jessie) with an openssl update (I don't yet have the details on package versions or any related details) Edit: running version 1.1 (not producible when reverted back to 1.0.2j).

    Here was the exception (host and other details in monero-project/kovri#453):

    ERR   HTTP: caught exception_ptr, rethrowing exception
    ERR   HTTP: Dynamic exception type: boost::system::system_error
    std::exception::what: stream truncated
    
  10. deanberris commented on Dec 15, 2016

    @deanberris
    Member

    Hi @anonimal -- is this something we can fix on the cpp-netlib side? Or is this something wrong with how ASIO is handling it? I'd appreciate a pull request to make this less of a problem for users.

  11. anonimal commented on Dec 15, 2016

    @anonimal

    Hi Dean, I don't know: I haven't looked deeper into the issue and, because of kovri-things, I won't be able to bug hunt anytime soon. I'll be happy to do that though when I can make the time to do so.

  12. HighCommander4 commented on Feb 11, 2018

    @HighCommander4

    I finally tracked it down to a std::exception_ptr being thrown directly.

    That's a bug in cpp-netlib, for which I filed #815.

  13. HighCommander4 commented on Feb 14, 2018

    @HighCommander4

    I am experiencing the same "stream truncated" error that was mentioned above. Does anyone know of a solution other than downgrading libssl to 1.0.2?

  14. HighCommander4 commented on Aug 7, 2019

    @HighCommander4

    This is still a problem with latest trunk.

  15. HighCommander4 commented on Aug 8, 2019

    @HighCommander4

    Applying the Boost.Asio patch from this ticket resolves the problem for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions