zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.62k stars 2.35k forks source link

Receive a few duplicated messages instead of all different with PUSH/PULL #4536

Closed ppolyanskiyy closed 1 year ago

ppolyanskiyy commented 1 year ago

Issue description

I receive a few duplicated messages instead of all different. The PUSH socket sends 5 different messages of the same size one by one. The PULL socket receives exactly 5 messages but some of them are duplicated, and some of them are not received.

I attach the file with most important part of wrapper for libzmq. ZmqWrapper.zip

Environment

Windows 10 Enterprise. Version 22H2. OS build 19045.2728

Minimal test code / Steps to reproduce the issue

  1. Create a PUSH socket for client
  2. Create a PULL socket for server
  3. In server use while loop calling receive
  4. In client send a few messages one by one

Important note: the context is create from one thread but send and receive is called from the different. (Means send is called from one thread, but not the same where context and socket is created, and receive from it's own)

What's the actual result? (include assertion message & call stack if applicable)

Receive same number of messages, but some of the are duplicated

What's the expected result?

Receive all different messages

bluca commented 1 year ago

Means send is called from one thread, but not the same where context and socket is created

sockets cannot be referenced from multiple threads

ppolyanskiyy commented 1 year ago

What do you mean by referenced? I create socket in one thread, but use it (e.g. call receive ) in second and no more threads are involved. Even if i put creation of socket into the same thread, the issue still reproduces.

mitchellwrosen commented 1 year ago

@ppolyanskiyy could you make a new issue then, without a repro that doesn't involve using a socket from a different thread that the one in which it was created?