1

I'm trying to use the http_listener in a larger MFC project of mine built in visual studio 2017 with platform toolset v141. The project statically links to other MFC based libraries that were built using v141_xp platform toolset. It runs fine until executing the code that links to the cpprestsdk. The cpprestsdk was installed using vcpkg, which built the cpprestsdk using the vc141 platform toolset. I do not know if the different versions of platform toolsets is an issue, but I don't know what else could be causing the problem.

My project has no known preexisting heap corruption issues, so the fact that this is causing a heap corruption is not making sense to me.

here is the offending line of code:

    utility::string_t port = U("34568");
    utility::string_t address = U("http://127.0.0.1:");
    address.append(port);

    web::uri_builder uri(address);

    auto addr = uri.to_uri().to_string();
    std::unique_ptr<http_listener> listener = std::make_unique<http_listener>(uri);
---->listener->open().wait();

If I move this code to the very beginning of the project, it will not crash on that line, however as soon as it receives an HTTP request it will crash in a similar manner.

Error info:

Critical error detected c0000374 Exception thrown at 0x7734A2B9 (ntdll.dll) in AuthenticationServer.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77384910). Unhandled exception at 0x7734A2B9 (ntdll.dll) in AuthenticationServer.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77384910).

Here is the call stack frame where the exception is being thrown:

pplx::task<void> http_server_api::register_listener(
    _In_ web::http::experimental::listener::details::http_listener_impl* listener)
{
----->  return pplx::create_task([listener]() {
        pplx::extensibility::scoped_critical_section_t lock(s_lock);
...
Alex
  • 712
  • 2
  • 13
  • 27

0 Answers0