使用cpprestsdk时发生堆损坏异常

问题描述 投票:1回答:1

我正尝试在Visual Studio 2017中使用平台工具集v141构建的我的大型MFC项目中使用http_listener。该项目静态链接到使用v141_xp平台工具集构建的其他基于MFC的库。在执行链接到cpprestsdk的代码之前,它运行良好。使用vcpkg安装了cpprestsdk,后者使用vc141平台工具集构建了cpprestsdk。我不知道平台工具集的不同版本是否有问题,但我不知道还有什么可能导致问题。

我的项目没有已知的预先存在的堆损坏问题,因此这导致堆损坏的事实对我来说没有意义。

这是令人反感的代码行:

    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();

如果将这段代码移到项目的最开始,它不会在该行崩溃,但是,一旦收到HTTP请求,它就会以类似的方式崩溃。

错误信息:

检测到严重错误c0000374抛出0x7734A2B9异常AuthenticationServer.exe中的(ntdll.dll):0xC0000374:已堆已损坏(参数:0x77384910)。 0x7734A2B9处未处理的异常AuthenticationServer.exe中的(ntdll.dll):0xC0000374:已堆已损坏(参数:0x77384910)。

这里是引发异常的调用堆栈帧:

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);
...
c++ visual-studio heap-corruption cpprest-sdk
1个回答
0
投票

我有同样的问题。想知道您是否找到了导致此堆损坏的根本原因?

© www.soinside.com 2019 - 2024. All rights reserved.