Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boost.ASIO integration stopped working with master #3269

Closed
hoditohod opened this issue Oct 8, 2018 · 8 comments
Closed

Boost.ASIO integration stopped working with master #3269

hoditohod opened this issue Oct 8, 2018 · 8 comments

Comments

@hoditohod
Copy link
Contributor

Issue description

Hi,
I'm using ZeroMQ and Boost.ASIO together in a Windows application. The zmq's internal signalig socket is retrieved with ZMQ_FD socket option, and passed to ASIO wrapped in a asio::ip::tcp::socket for completion handler notification. The logic is identical to the one in AZMQ: a duplicate handle is passed, no read/write performed on the ZMQ_FD socket itself. Asio is using IOCP.

This mechanism was working fine with libzmq 4.2.5 but fails master from mid august. I get an exception in the tcp::socket constructor: 'assign: The parameter is incorrect'. If I disable the IOCP backend in ASIO it starts working again. I found something similar on StackOverflow stating that the operation fails in CreateIoCompletionPort because the socket is already associated to an IOCP.

I suspect the most recent zmq poller code uses IOCP on windows and that causes the hickup with boost. I'm not familiar with IOCP's at all. Do you think this is the case? Do I have other options than disabling IOCP in either boost or libzmq?

@rodgert Did you experience this with AZMQ?

Environment

Win7 and Win10
Boost 1.62
VS2017
libzmq version (commit hash if unreleased): libzmq master aug. 15 (2cdad3d)

@bluca
Copy link
Member

bluca commented Oct 8, 2018

There's no usage of IOCP here, so it must be something else. Probably the switch to epoll by default? Have you tried forcing back to select?
@sigiesec any idea?

@hoditohod
Copy link
Contributor Author

I'm using CMake and VS2017 for the build, I don't pass any flags to CMake apart from the BUILD_TYPE=RelWithDebInfo.

The output is:
-- Using polling method in I/O threads: select
-- Using polling method in zmq_poll(er)_* API: select

So it's probably not wepoll... I'll try to track down the commit, and double check on my side.

@bluca
Copy link
Member

bluca commented Oct 8, 2018

yeah try to bisect and see what comes up

@sigiesec
Copy link
Member

sigiesec commented Feb 5, 2019

Could you provide some example code using Boost.Asio and libzmq that reproduces this? Then I can give it a look.

@enricodetoma
Copy link

enricodetoma commented Mar 26, 2019

Example that reproduces the behavior.
Windows 10 - Visual C++ 2017 - Boost 1.68 - AZMQ - x64 build

#define _WIN32_WINNT 0x0A00
#include <iostream>
#include <boost/asio.hpp>
#include <azmq/socket.hpp>

using namespace boost::asio;

void main ()
{
	io_service service;
	io_service::work work (service);

	try {
		azmq::rep_socket socket (service);
	}
	catch (std::exception &e) {
		std::cout << e.what ();
	}
}

Output:

assign: Parametro non corretto

@sigiesec
Copy link
Member

With some existing builds I found that 2aa54d6 was still fine, while d7e51cd was not. I will try to extract a libzmq test case from what boost::asio/azmq do, and the bisect.

@sigiesec
Copy link
Member

Bisecting showed that 2d9a895 is the first bad commit

@sigiesec
Copy link
Member

I found a simple solution. In the call to WSASocket, WSA_FLAG_OVERLAPPED must also be specified.

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

No branches or pull requests

4 participants