简体   繁体   English

在Windows上从1_55更新为1_62后,在LIB中创建boost :: asio :: ip :: udp :: socket崩溃

[英]Creating a boost::asio::ip::udp::socket crashing in LIB after updating from 1_55 to 1_62 on Windows

This is driving me nuts. 这让我发疯。 Mainly because it happens 90% of the time, but occasionally I can get right by it. 主要是因为它有90%的时间会发生,但偶尔我会正确处理。

So here's the backstory. 所以这是背景故事。 I had compiled boost 1_55 using MSVC++ 2012, and we had been using it for quite a while. 我已经使用MSVC ++ 2012编译了boost 1_55,我们已经使用了一段时间了。 We are switching over to the 2013 toolchain finally and I've been tasked with upgrading everything. 最终,我们将切换到2013年的工具链,我的任务是升级所有内容。

I chose to grab the latest boost 1_62, and recompile with the 2013 32-bit toolset. 我选择使用最新的Boost 1_62,并使用2013 32位工具集重新编译。 The problem I'm having is that now that I've recompiled I am getting a crash on creating a udp socket. 我遇到的问题是,现在重新编译后,我在创建udp套接字时崩溃了。

So I have a library that we developed that we link statically. 因此,我有一个我们开发的库,该库可以静态链接。 I inherit from that library and call a method that opens a UDP Port. 我从该库继承并调用一个打开UDP端口的方法。

For the sake of the example I have changed my code to best illistrate this point: 为了这个例子,我更改了代码以最好地说明这一点:

In the class constructor I have the following: 在类构造函数中,我具有以下内容:

        boost::asio::io_service test;
        boost::asio::ip::udp::socket socket(test);

        this->StartListen();

That works just fine. 那很好。 In StartListen, I call Init I have the following: 在StartListen中,我称Init为以下内容:

        boost::asio::ip::udp::endpoint listen_endpoint(
        boost::asio::ip::address::from_string(m_bindAddress), m_usPort);
    m_mcast_endpoint.reset(new boost::asio::ip::udp::endpoint(
        boost::asio::ip::address::from_string(m_sendAddress), m_usPort));
    m_socket.reset(new boost::asio::ip::udp::socket(m_ioservice));

This blows up on the m_socket.reset with this: 这在m_socket.reset上炸毁了:

Unhandled exception at 0x77D798C1 (ntdll.dll) in program.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77DAC8D0).

Interestly enough when I changed the example to be the immediately in the start listen like this: 有趣的是,当我将示例更改为立即开始收听时,如下所示:

  void Multicast::StartListen()
{
    boost::asio::io_service take2;
    boost::asio::ip::udp::socket socket_test(take2);

I get this: 我得到这个:

Unhandled exception at 0x6384D4A1 in program.exe: 0xC00001A5: An invalid exception handler routine has been detected (parameters: 0x00000003).

I really have no idea what's going on here. 我真的不知道这是怎么回事。 I built boost with the 我用

b2.exe --build-type=complete --stagedir=bin32 address-model=32 stage b2.exe --build-type = complete --stagedir = bin32地址模型= 32阶段

and everything seems correct. 一切似乎都是正确的。 What am I missing? 我想念什么?

Well I've made more progress. 好吧,我取得了更多进步。 The issue happens when you create a boost UDP socket in a library, and create a boost UDP socket in the code calling the library. 当您在库中创建boost UDP套接字,并在调用该库的代码中创建boost UDP套接字时,会发生此问题。

So: 
Main 
| 
| Create UDP Socket 
| 
CALL LIBRARY 
 | 
 | 
 | Create UDP SOCKET <--- Heap corruption

也许您使用1_55的标头进行编译,但使用1_62的库进行链接

The problem was with Boost.ASIO and using it from two separate projects. 问题出在Boost.ASIO并在两个不同的项目中使用它。 Putting the BOOST_ASIO_DISABLE_IOCP define in both project properties fixed the problem. 将BOOST_ASIO_DISABLE_IOCP定义放入两个项目属性中可以解决此问题。 There is probably a "better way" of using IOCP, but this solved it going forward. 可能有使用IOCP的“更好的方法”,但这解决了它的发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 boost::asio::ip::udp::socket::receive_from 在 Windows 中不抛出中断异常? - Why doesn't boost::asio::ip::udp::socket::receive_from throw interruption exception in Windows? 无法编译boost :: asio :: basic_datagram_socket <boost::asio::ip::udp> :: basic_datagram_socket() - Cannot compile boost::asio::basic_datagram_socket<boost::asio::ip::udp>::basic_datagram_socket() 将asio udp套接字发送到不同的ip地址 - Boost asio udp socket sending to different ip address Boost Asio UDP服务器设置套接字监听指定的IP - Boost Asio UDP server set socket to listen on specified IP 可能 boost::asio::ip::udp::socket::send_to 甚至失败? - May boost::asio::ip::udp::socket::send_to even fail? 从boost :: asio :: ip :: tcp :: socket继承的自定义套接字 - Custom Socket Inheriting from boost::asio::ip::tcp::socket 使用istream从boost :: asio UDP套接字检索float - Retrieving float from boost::asio UDP socket using istream 如何从 boost::asio::ssl::stream 获取本机套接字文件描述器<boost::asio::ip::tcp::socket> ?</boost::asio::ip::tcp::socket> - How to get native socket file describer from boost::asio::ssl::stream<boost::asio::ip::tcp::socket>? udp(boost :: asio)在async_receive_from之后读取错误 - udp (boost::asio) read error after async_receive_from 在Windows中使用Boost asio重新连接套接字 - Reconnect a socket with Boost asio in Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM